github添加ssh key以及常见的问题

参考博客:

https://www.cnblogs.com/ailhc/p/6586465.html

https://www.cnblogs.com/cnlg123/p/7762889.html

https://www.cnblogs.com/xixihuang/p/5522424.html

大家方法都差不多,我这里主要是解决了Permission denied (publickey).和git clone的错误。

------------------------------------正文------------------------------------

 所用到命令

git config --global user.name "guyongpu"
git config --global user.email  "gyphust@qq.com"
rm -rf ~/.ssh/*
cd ~/.ssh
ssh-keygen -t rsa -C "gyphust@qq.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat id_rsa.pub
/*将id_rsa.pub的内容复制到github中*/
ssh -T git@github.com
ssh-add ~/.ssh/id_rsa

截图:

 将id_rsa.pub的内容复制到github即可,此步骤很简单,不再赘述

常见的问题:

问题1:添加ssh key报错

yongpu@ubuntu:~/.ssh$ ssh -T git@github.com
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).

解决办法:输入 
 

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

问题2: git clone报错

sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决办法:

eval "$(ssh-agent -s)"
然后在git clone等操作,clone项目的时候选择ssh方式

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值