生成新的ssh密鑰
ssh-keygen -t rsa -b 4096 -C "[email protected]"
不要一直回車鍵,輸入新的名稱 id_rsa_new
Enter a file in which to save the key (/Users/you/.ssh/id_rsa):id_rsa_new
啓動ssh-agent
$ eval "$(ssh-agent -s)"
> Agent pid 59566
將SSH私鑰添加到ssh-agent並將密碼存儲在密鑰鏈中
ssh-add ~/.ssh/id_rsa_new
需要修改~/.ssh/config文件以自動將密鑰加載到ssh-agent中並在密鑰鏈中存儲密碼
Host new
HostName github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa_new
User test
Host old
HostName github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
User test
回到GitHub賬號添加祕鑰不再複述
請看link
ssh -T git@new
測試鏈接,如下繼續連接 yes
> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
> Are you sure you want to continue connecting (yes/no)?
或
> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)?
如下,出現successfully表示成功
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
添加倉庫地址 Host 對應config中的配置
git remote add origin git@:xxxx/test.git
這樣就可以實現管理多個GitHub項目
win系統配置過程會出現更多問題,再敘。。