Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

之前使用git進(jìn)行push或者clone操作的時候出現(xiàn)如下錯誤:

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了。

設(shè)置Git的user nameemail

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

生成SSH密鑰

查看是否已經(jīng)有了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.pub

在github上添加ssh密鑰,這要添加的是“id_rsa.pub”里面的公鑰。打開github在設(shè)置中添加密鑰


按照指令操作會進(jìn)入vim編輯模式,上邊的序列碼即為公鑰,復(fù)制序列碼,包含(ssh-rsa等標(biāo)識)。不同操作系統(tǒng)和電腦可能公鑰路徑不一樣,以實際情況為準(zhǔn).
登錄github后,進(jìn)入個人設(shè)置settings--->ssh and gpg keys-->new ssh key 添加即可。title自行命名


add ssh key成功后,github就可以識別你的機(jī)器,允許你從github拉取代碼了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容