ssh: connect to host github.com port 22: Connection refused

问题:

$ git push

ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

排查:

错误提示的是连接github.com的22端口被拒绝了,那我们换个端口试一试。

解决:

22端口可能被防火墙屏蔽了,可以尝试连接GitHub的443端口。

$ vim ~/.ssh/config
```
# 给~/.ssh/config文件里添加如下内容
Host github.com
  Hostname ssh.github.com
  Port 443
```

如果~/.ssh目录下没有config文件,手动新建一个即可。

然后测试一下:

$ ssh -T [email protected]
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

Reference

https://zhuanlan.zhihu.com/p/521340971

你可能感兴趣的:(坑,ssh,github,运维)