Github-ssh:connect to host github.com port 22: Connection timed out 亲测有效

137 阅读1分钟

解决Github报错:ssh:connect to host github.com port 22: Connection timed out

今天ssh方式提交代码,突然大姨妈。三角函数懵逼!

image.png

解决方案

如果22号端口不行,那就换一个端口呗!

进入.ssh文件夹

cd ~
cd .ssh

新建一个config文件

vim config
cd .ssh

Config内容如下:

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

测试结果

需要手动输入一次 yes

ssh -T git@github.com

image.png