原因分析
Permission denied (publickey) 沒(méi)有權(quán)限的publickey ,出現(xiàn)這錯(cuò)誤一般是以下兩種原因
- 客戶(hù)端與服務(wù)端未生成 ssh key
- 客戶(hù)端與服務(wù)端的ssh key不匹配
找到問(wèn)題的原因了,解決辦法也就有了,重新生成一次ssh key ,服務(wù)端也重新配置一次即可。
客戶(hù)端生成ssh key
ssh-keygen -t rsa -C "470812087@qq.com"
470812087@qq.com改為自己的郵箱即可,途中會(huì)讓你輸入密碼啥的,不需要管,一路回車(chē)即可,會(huì)生成你的ssh key。(如果重新生成的話(huà)會(huì)覆蓋之前的ssh key。)?
然后再終端下執(zhí)行命令:
ssh -v git@github.com
最后兩句會(huì)出現(xiàn)
-
No more authentication methods to try.
-
Permission denied (publickey).
在終端再執(zhí)行以下命令
ssh-agent -s
接著在執(zhí)行
ssh-add ~/.ssh/id_rsa
$ ssh-add ~/.ssh/id_rsa
出現(xiàn)Could not open a connection to your authentication agent.
這時(shí)可以使用:ssh-agent bash
?命令,然后再次使用ssh-add ~/.ssh/id_rsa_name
這個(gè)命令就沒(méi)問(wèn)題了。
如下:
Identity added: ...這是ssh key文件路徑的信息
配置服務(wù)端
打開(kāi)你剛剛生成的id_rsa.pub,將里面的內(nèi)容復(fù)制,進(jìn)入你的github賬號(hào),在settings下,SSH and GPG keys下new SSH key,然后將id_rsa.pub里的內(nèi)容復(fù)制到Key中,完成后Add SSH Key。
title隨便起?
驗(yàn)證Key
ssh -T git@github.com
-
$ ssh -T git@github.com
-
Hi 470812087! You've successfully authenticated, but GitHub does not provide shell access.
提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. 問(wèn)題就解決啦文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-760776.html
解決git@github.com: Permission denied (publickey). Could not read from remote repository_ywl470812087的博客-CSDN博客文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-760776.html
到了這里,關(guān)于解決git@github.com: Permission denied (publickey). Could not read from remote repository的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!