關(guān)于github【Permission denied (publickey)】

之前一直用的好好的github,不知怎么ssh提示這個(gè)了,于是重新弄了一下ssh

我重新做了一遍記錄流程

1.設(shè)置Git的user name和email

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

2.生成SSH密鑰

查看是否已經(jīng)有了ssh密鑰:cd ~/.ssh
如果沒(méi)有密鑰則不會(huì)有此文件夾,有則備份刪除
生成密鑰:
ssh-keygen -t rsa -C “xxxxx@gmail.com”
按3個(gè)回車,密碼為空。
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:
………………

3.最后得到了兩個(gè)文件:id_rsa和id_rsa.pub

添加密鑰到ssh:進(jìn)入你的github,需要之前輸入密碼.

在github上添加ssh密鑰,這要添加的是“id_rsa.pub”里面的公鑰。

打開https://github.com/
在設(shè)置中添加密鑰

把id_rsa.pub用記事本打開之后復(fù)制里面的到網(wǎng)站上就可以了。

之后在terminal輸入:ssh git@github.com
The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? 
輸入yes就可以了

測(cè)試成功就來(lái)push你的代碼吧

后記:如果你碰巧出現(xiàn)下面這樣的問(wèn)題:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
Permissions 0666 for '/home/robin/.ssh/id_rsa' are too open.  
It is recommended that your private key files are NOT accessible by others.  
This private key will be ignored.  
bad permissions: ignore key: /home/robin/.ssh/id_rsa

那么來(lái)嘗試這樣做吧

chmod 755 ~/.ssh/  
chmod 600 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub   
chmod 644 ~/.ssh/known_hosts 

然后再進(jìn)行測(cè)試,你就會(huì)發(fā)現(xiàn),we get it!

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

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

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