如題,git使用中突然報錯
ssh:connect to host github.com port 22: Connection timed out
通過查閱各種資料,得知原因可能是由于電腦的防火墻或者其他網(wǎng)絡(luò)原因?qū)е聅sh連接方式 端口22被封鎖。
解決方法
一:拋棄ssh連接方式,使用http連接。
git config --local -e
將配置文件的url = git@github.com:username/repo.git一行改為:url = https://github.com/username/repo.git
方法二:如果22號端口不行,那就換一個端口
進入.ssh文件夾
創(chuàng)建一個config文件
將下面的內(nèi)容復(fù)制進去
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
保存退出
檢查是否成功
ssh -T git@github.com
這里要根據(jù)它的提示操作,有個地方要輸入yes文章來源:http://www.zghlxwxcb.cn/news/detail-751802.html
此時大功告成啦文章來源地址http://www.zghlxwxcb.cn/news/detail-751802.html
到了這里,關(guān)于【git】解決git報錯:ssh:connect to host github.com port 22: Connection timed out 親測有效的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!