操作系統(tǒng) Windows11
使用Git IDEA
連接方式:SSH
今天上傳代碼出現(xiàn)如下報(bào)錯(cuò):ssh:connect to host github.com port 22: Connection timed out
再多嘗試幾次,依然是這樣。
解決
最終發(fā)現(xiàn)兩個(gè)解決方案:(二選一)
方法一: 拋棄ssh連接方式,使用http連接。(我試了一下,對(duì)于我來說沒有用)
操作方法:
輸入命令:git config --local -e
將配置文件的url = git@github.com:username/repo.git
一行改為:url = https://github.com/username/repo.git
方法二: 如果22號(hào)端口不行,那就換一個(gè)端口
操作方法:
1.進(jìn)入~/.ssh下cd ~/.ssh
2.創(chuàng)建一個(gè)config文件vim config
3.編輯文件內(nèi)容:
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
4.保存退出
5.檢查是否成功ssh -T git@github.com
這里要根據(jù)它的提示操作,有個(gè)地方要輸入yes
出現(xiàn): Hi 什么什么的 就是成功了文章來源:http://www.zghlxwxcb.cn/news/detail-686890.html
大功告成,這時(shí)候再試試git push,已經(jīng)可以提交了!文章來源地址http://www.zghlxwxcb.cn/news/detail-686890.html
到了這里,關(guān)于Git問題:解決“ssh:connect to host github.com port 22: Connection timed out”的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!