1. 报错信息
# git push
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
2. 以前是可以使用的,突然无法push,找了些方法,如重新添加ssh key,最后想到换了网络环境,可能是防火墙导致无法访问22端口
3. 解决步骤
1)测试可用性
ssh -T -p 443 git@ssh.github.com
提示如下证明可用
Hi username! You’ve successfully authenticated, but GitHub does not
provide shell access.
或
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ssh.github.com]:443,[20.205.243.160]:443' (ECDSA) to the list of known hosts.
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
2)编辑~/.ssh/config 文件
本windows下,路径为C:\Users\用户名\.ssh,没有config文件则添加一个,没有后缀。再该config文件中添加内容
Host github.com
Hostname ssh.github.com
Port 443
3)再次测试
ssh -T git@github.com
提示如下即可用
|
个人学习记录,侵删
参考:
解决 ssh: connect to host github.com port 22: Connection timed out - SegmentFault 思否