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

相關文章
相關標籤/搜索