Permission denied (publickey)

1、檢查是否鏈接:

ssh -T git@github.com

2、對(duì)比本地的公鑰指紋和線(xiàn)上的公要指紋是否一致:

查看本地公要指紋

如果您使用的是OpenSSH 6.7或更早版本

eval "$(ssh-agent -s)"
>Agent pid 59566
ssh-add -l
>2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)

如果您使用的是OpenSSH 6.8或更新版本:

eval "$(ssh-agent -s)"
>Agent pid 59566
ssh-add -l -E md5
>2048 MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)
查看倉(cāng)庫(kù)公鑰指紋
image.png

如果以上都沒(méi)問(wèn)題,應(yīng)該是被公司網(wǎng)絡(luò)或者防火墻攔截了。

通過(guò)HTTPS端口使用SSH

要測(cè)試是否可以通過(guò)HTTPS端口進(jìn)行SSH,請(qǐng)運(yùn)行以下SSH命令:
ssh -T -p 443 git@ssh.github.com
>Hi username! You've successfully authenticated, but GitHub does not
>provide shell access.
如果您能夠git@ssh.github.com通過(guò)端口443 進(jìn)行SSH ,則可以覆蓋SSH設(shè)置以強(qiáng)制任何與GitHub的連接通過(guò)該服務(wù)器和端口運(yùn)行。
要在ssh配置中設(shè)置此項(xiàng),請(qǐng)?jiān)谝韵挛恢镁庉嬙撐募/.ssh/config,然后添加以下部分:
Host github.com
  Hostname ssh.github.com
  Port 443
  IdentityFile  ~/.ssh/id_rsa 
  IdentitiesOnly yes

IdentityFile是用來(lái)配置私鑰文件,當(dāng)你的電腦有兩個(gè)或以上倉(cāng)庫(kù)要提交

您可以通過(guò)再次連接到GitHub來(lái)測(cè)試這是否有效:
ssh -T git@github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.

參考:https://help.github.com/en/articles/using-ssh-over-the-https-port

最后編輯于
?著作權(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)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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