git@github.com: Permission denied (publickey). fatal: Could not read from remote

前端晉級攻城獅發表於2019-12-13

開啟Git輸入命令

git config –global user.name “yourname”回車

git config –global user.email“your@email.com”回車

刪除.ssh資料夾(直接搜尋該資料夾)下的known_hosts(手動刪除即可,不需要git)

ssh-keygen -t rsa -C “your@email.com”(填寫自己的郵箱地址)回車

Enter file in which to save the key (/root/.ssh/id_rsa):

然後系統會自動在.ssh資料夾下生成兩個檔案,id_rsa和id_rsa.pub,用記事本開啟id_rsa.pub

進入自己的賬號https://github.com/settings/keys 點選 New sshKey

複製的內容貼上到Key裡,Title可以不寫,預設是郵箱

驗證:$ ssh -T git@github.com回車

git@github.com: Permission denied (publickey). fatal: Could not read from remote

如果出現錯誤 You've successfully authenticated, but Gitee.com does not provide she access.

執行 git pull origin master --allow-unrelated-histories

最後關聯遠端分支git push --set-upstream origin master

ok,成功!!!

相關文章