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

ssh: connect to host github.com port 22: Connection refused 是连接github.com的端口号22拒绝连接。

可以使用github的443端口。

解决方案

  1. ~/.ssh/config中添加如下字段:
$ vim ~/.ssh/config
# 如果没有config 文件就新建一个
Host github.com
  Hostname ssh.github.com
  Port 443
  1. 测试是否链接成功
ssh -T [email protected]

如果出现如下字段则验证成功
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 githubName! You’ve successfully authenticated, but GitHub does not provide shell access.

你可能感兴趣的:(问题解决,ssh,github,运维)