Github无法clone代码?没有权限?试试这种方法

异常信息:

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.
[email protected]: 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
Github无法clone代码?没有权限?试试这种方法_第1张图片
5.找到SSH and GPG keys,然后点击New SSH key
Github无法clone代码?没有权限?试试这种方法_第2张图片
Github无法clone代码?没有权限?试试这种方法_第3张图片
Title是指别名;
key是指~/.ssh/id_rsa里面的内容,添加进去之后,点击Add SSH key
6.最后,测试一下
使用命令:ssh -T [email protected]
结果:

Hi GoldWater16! You've successfully authenticated, 
but GitHub does not provide shell access.

出现以上这种提示,说明成功了,你就可以愉快的玩耍了。

你可能感兴趣的:(软件工具,git,github)