欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ssh: connect to host github.com port 22: Connection timed out

程序员文章站 2024-03-14 09:04:16
...

安装的git版本如下:
ssh: connect to host github.com port 22: Connection timed out
今天在添加SSH key到github时出现以下错误:
ssh: connect to host github.com port 22: Connection timed out
解决方法如下:

  1. 找到git的安装目录,找到/etc/ssh/ssh_config文件:
    ssh: connect to host github.com port 22: Connection timed out
  2. 打开后,在末尾增加以下内容:
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

ssh: connect to host github.com port 22: Connection timed out
然后:
ssh: connect to host github.com port 22: Connection timed out
就成功了。