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.
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.

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

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨润泽林

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值