首页 » 操作系统 » Mac » 解决MacOS Sierra更新后ssh无密码登陆频繁输入ssh passphrase

解决MacOS Sierra更新后ssh无密码登陆频繁输入ssh passphrase

 

更新到MacOS Sierra后,发现一个问题,不管是git还是ssh无密码登陆,
如果自己ssh-keygen生成的id_rsa.pub是带有密码的话,
之后只要ssh无密码登陆,或者操作git都需要频繁输入这个ssh passphrase.

找了半天,结果
原因就是Sierra之后OSX 不再保存SSH keys到keychain了.

其实就是为了防止客户端被盗,服务器或者git就被攻击

man ssh_config
里面有句话是:

UseKeychain
On macOS, specifies whether the system should search for
passphrases in the user's keychain when attempting to use a par-
ticular key. When the passphrase is provided by the user, this
option also specifies whether the passphrase should be stored
into the keychain once it has been verified to be correct. The
argument must be yes'' orno''. The default is ``no''.

解决办法

增加 ~/.ssh/config文件:

Host *
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_rsa

或者使用

ssh-add -K



原文链接:解决MacOS Sierra更新后ssh无密码登陆频繁输入ssh passphrase,转载请注明来源!

0