Mac OS Sierra SSH密鑰在重啟后丟失的問(wèn)題

最近MacBook系統(tǒng)出了點(diǎn)問(wèn)題,遂重裝了最新的系統(tǒng)macOS Sierra。然鵝,問(wèn)題來(lái)了。以前在終端中使用SSH,若要將key永久保存在本地,只需要執(zhí)行ssh-add -K "KeyPath"命令即可。而現(xiàn)在執(zhí)行此命令雖然依舊能保存成功,但是在“鑰匙串”中找不到保存的SSH密鑰,也就是說(shuō)并沒(méi)有持久化保存到KeyChain中,重啟后測(cè)試,果然ssh密鑰清空了。

研究了一下,原來(lái)問(wèn)題出在系統(tǒng)上,從macOS Sierra 10.12.2以后,SSH的配置選項(xiàng)中多了“UseKeychain”選項(xiàng),在man ssh_config頁(yè)面中有這樣的介紹:

UseKeychain
On macOS, specifies whether the system should search for
passphrases in the user's keychain when attempting to use a particular 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''.

要解決這個(gè)問(wèn)題,就要借助于UseKeychain選項(xiàng)。在~/.ssh/config文件中添加下面這段話,問(wèn)題就可以解決了:

Host *
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_rsa
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容