當在遠程庫上設置了SSH 之后還是報錯連接超時,問題如下
$ git push origin master
報錯:
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
這個時候需要檢查一下SSH是否能夠連接成功,輸入以下命令
ssh -T git@github.com
稍等片刻如果繼續報錯,如下:
ssh: connect to host github.com port 22: Connection timed out則,可以使用一下解決辦法
打開存放ssh的目錄
cd ~/.ssh
ls
查看是否存在 id_rsa id_rsa.pun known_hosts 三個文件,如果沒有移步解決辦法:
1. vim config (進入到vim編輯界面)
2. insert 編輯模式
Host github.com
User YourEmail@163.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
其中, YourEmail 為綁定的郵箱。
保存之后再次執行"ssh -T git@github.com"時,會出現如下提示,回車"yes"即可。
這時驗證就可以通過。
最后就可以繼續上傳代碼了。
本文解決方法參考 : https://blog.csdn.net/qq_42146613/article/details/82772734