Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
出现这个问题是因为,没有在github账号添加SSH key
解决方法如下
在终端输入。
1.首先,如果你没有ssh key的话,在ternimal下输入命令:ssh-keygen -t rsa -C "youremail@example.com", youremail@example.com改为自己的邮箱即可,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)
2.然后再ternimal下执行命令:
ssh -v git@github.com
最后两句会出现:
No more authentication methods to try.
Permission denied (publickey).
3.这时候再在ternimal下输入:
ssh-agent -s
然后会提示类似的信息:
SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK;
SSH_AGENT_PID=13144; export SSH_AGENT_PID;
echo Agent pid 13144;
4.接着再输入:
ssh-add ~/.ssh/id_rsa
这时候应该会提示:
Identity added: ...(这里是一些ssh key文件路径的信息)
(注意)如果出现错误提示:
Could not open a connection to your authentication agent.
请执行命令:eval `ssh-agent -s`后继续执行命令 ssh-add ~/.ssh/id_rsa,这时候一般没问题啦。
5.打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。
6.最后一步,验证Key
在ternimal下输入命令:
ssh -T git@github.com
提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.