ssh: connect to host github.com port 22: Connection timed out
·
问题描述

使用Mac安装Git后,通过ssh -T git@github测试连接时出现如下错误:通过ping能够ping通github.com。
ssh: connect to host github.com port 22: Connection timed out
解决方案
【1】进去.ssh目录查看是否存在config文件,不存在则通过如下命令创建:
# 通过cd命令进入.ssh文件夹
cd ~/.ssh
# 通过 ls -la 查看文件
ls -la
# 当不存在 config 文件时则创建
touch config
【2】将下面内容粘贴到config文件中:需要将邮件更换为自己的邮件
Host github.com
User 注册github的邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
【3】在Mac终端重新进行测试:
ssh -T git@github
# 出现如下内容,输入 yes 即可 , 此时git就恢复了正常
Please type `yes`, `no` or the fingerprint: yes
更多推荐



所有评论(0)