ssh: connect to host XX.XX.XX.XX port 22: Connection timed out

206 阅读1分钟

背景:

今天在拉取线上代码的时候时,出现ssh: connect to host XX.XX.XX.XX port 22: Connection timed out报错

解决办法1:

  1. 命令行输入命令git config --local -e-

  2. 把原本的git仓库地址(SSH)换成HTTP链接

image.png

红线部分是SSH地址

解决办法2:

在项目的.ssh目录下新建一个config文件,输入如下内容

Host github.com 
User xxx@qq.com (你github的邮箱) 
Hostname ssh.github.com 
PreferredAuthentications publickey 
IdentityFile ~/.ssh/id_rsa 
Port 443 

然后输入如下命令

ssh -T git@github.com

出现Hi xxx!……表示成功