Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you ha

以前使用git进行push或者clone操做的时候出现以下错误:git

Permission denied (publickey).
fatal: Could not read from remote repository.

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

缘由:电脑公钥(publickey)未添加至github,因此没法识别。 于是须要获取本地电脑公钥,而后登陆github帐号,添加公钥至github就OK了。github

设置Git的user nameemailvim

git config --global user.name "yourname"
git config --global user.email "youremail"

生成SSH密钥ssh

查看是否已经有了ssh密钥:cd ~/.ssh
若是没有密钥则不会有此文件夹,有则备份删除
生存密钥:
ssh-keygen -t rsa -C “youremail”
按3个回车,密码为空。
Your identification has been saved in /home/tekkub/.ssh/id_rsa.Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.The key fingerprint is:
………………
最后获得了两个文件:id_rsaid_rsa.pubide

在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。打开github在设置中添加密钥加密

 

按照指令操做会进入vim编辑模式,上边的序列码即为公钥,复制序列码,包含(ssh-rsa等标识)。不一样操做系统和电脑可能公钥路径不同,以实际状况为准.
登陆github后,进入我的设置settings--->ssh and gpg keys-->new ssh key 添加便可。title自行命名操作系统

 

add ssh key成功后,github就能够识别你的机器,容许你从github拉取代码了。code

相关文章
相关标签/搜索