MacOS升级sierra后,git不能push也不能pull的解决方案

macOS Sierra 10.12 SSH Keys

I updated to macOS Sierra 10.12 (GM) tonight and surprisingly everything seemed to work without any issues … at least so far. One thing that did come up, but was easily remedied, was that all of my SSH keys stopped working.

ssh git@github.com

The above command prompted for a password (assuming you use GitHub), which is should not do if SSH keys are set up properly.

Assuming your SSH keys are RSA-based, I have a quick solution:

  1. cd ~/.ssh
    1. This will get us into our user SSH folder
  2. ssh-add -l
    1. This lists all keys that the SSH agent knows about. After upgrading, this returned zero keys! Note: In reality ssh-add is session-based, and so each time you log in this command will show zero results (see below).
  3. ssh-add -K ~/.ssh/[your-private-ssh-key-name]
    1. You’ll be asked for the password (if one is set) for this private key
      1. -K tells ssh-add to save the key into your Keychain, so that on subsequent logins, even if ssh-add -l shows nothing, ssh will also look in your Keychain to see if the key is save there.
    2. [your-private-ssh-key-name] is likely id_rsa, but it could be others as well
    3. Repeat step 3 as needed
  4. ssh-add -l
    1. You should now see you SSH key(s) listed

That worked for me, though oddly I had to do this process twice as the first time I made it to step four, then exited Terminal, none of my applications using SSH worked, I opened Terminal again and found that nothing was listed when I ran the ssh-add list command.

UPDATE:

This doesn’t seem to do what I thought it should, namely, upon reboot I had to repeat this process again. I have since added the following steps:

cd ~/.ssh/
sudo vim config

I then added this line to my SSH confile:

IdentityFile ~/.ssh/[your-private-ssh-key-name]

I saved the config file, and now my SSH keys work as expected.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值