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  "[email protected]"
rm -rf ~/.ssh/*
cd ~/.ssh
ssh-keygen -t rsa -C "[email protected]"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cat id_rsa.pub
/*将id_rsa.pub的内容复制到github中*/
ssh -T [email protected]
ssh-add ~/.ssh/id_rsa

截图:

github添加ssh key以及常见的问题_第1张图片

 将id_rsa.pub的内容复制到github即可,此步骤很简单,不再赘述github添加ssh key以及常见的问题_第2张图片

github添加ssh key以及常见的问题_第3张图片

github添加ssh key以及常见的问题_第4张图片

常见的问题:

问题1:添加ssh key报错

yongpu@ubuntu:~/.ssh$ ssh -T [email protected]
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.

github添加ssh key以及常见的问题_第5张图片

解决办法:

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

github添加ssh key以及常见的问题_第6张图片

github添加ssh key以及常见的问题_第7张图片

 

你可能感兴趣的:(学习)