异常信息:
The authenticity of host 'github.com (192.30.0.0)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,192.30.0.0' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决方案:
1.先检查你的电脑是否存在SSH KEY
执行命令:ls ~/.ssh
会出现:id_rsa id_rsa.pub known_hosts
这三个东东
2.如果没有以上文件,需要执行以下命令创建
执行命令:ssh-keygen -t rsa -C "你的邮箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/goldwater/.ssh/id_rsa):
会让你选择保存在哪个目录下,我是直接保存在/Users/goldwater/.ssh
下,其他几个选项直接回车就可以了,直接使用默认。
3.复制~/.ssh/id_rsa.pub
的文件内容
4.打开github,找到settings
5.找到SSH and GPG keys,然后点击New SSH key
Title是指别名;
key是指~/.ssh/id_rsa
里面的内容,添加进去之后,点击Add SSH key
6.最后,测试一下
使用命令:ssh -T git@github.com
结果:
Hi GoldWater16! You've successfully authenticated,
but GitHub does not provide shell access.
出现以上这种提示,说明成功了,你就可以愉快的玩耍了。