在公司的电脑上增加一个私人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