Git多賬號配置

在公司的電腦上增加一個私人Git賬號,遇到的問題和解決方案,記錄一下。

1. 執行ssh-add ~/.ssh/id_rsa_elise,報錯:Could not open a connection to your authentication agent
解決方案:
先執行 ssh-agent 或 eval `ssh-agent`,再執行 ssh-add

2. 連接時報錯:Permission denied (publickey).
解決方案:
git默認使用id_rsa,而我新建祕鑰時用了自定義的名稱,此時必須配置config文件:
cd ~/.ssh/vi config
#Host host(Host簡稱,使用命令ssh host可連接遠程服務器,如:ssh github)
  #User/Email 登錄用戶名(如:elise/[email protected])
  #HostName 主機名用ip或域名(如:github.com)
  #Port 服務器open-ssh端口(默認:22)
  #IdentityFile 私鑰的路徑
Host github.com
  HostName github.com
  User elise
  IdentityFile ~/.ssh/id_rsa_elise

保存退出後再 ssh -T [email protected],成功

3. Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts. Permission denied (publickey).
解決方案:在hosts文件中加入 13.229.188.59 github.com

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章