自定义 SSH 配置不起作用

问题描述 投票:0回答:1

我一直在尝试让 ssh 使用端口 443 连接到 Github,我决定使用

~/.ssh/config
处的自定义 ssh 配置文件。创建文件并设置正确的文件权限后,我尝试再次连接,但端口 22 上的连接仍然超时。我知道这一点是因为端口 22 被我的 ISP 阻止(由于某些奇怪的原因)。

$ cd ~/.ssh
$ touch config
$ chown $USER config
$ chmod 644 config

然后在配置文件中添加以下内容:

Host pagodabox.io
  HostName git.pagodabox.io
  Port 443

Host github.com
  HostName ssh.github.com
  Port 443

然后我尝试从我的 iTerm 应用程序中调用它。

$ ssh -T [email protected]

我收到错误:

ssh:连接到主机 ssh.github.com 端口 22:操作超时致命:无法从远程存储库读取。

请确保您拥有正确的访问权限并且存储库存在。

但是,如果我这样做

$ ssh -T -p 443 [email protected] 

我得到了想要的回应。

嗨[用户名]!您已成功通过身份验证,但 GitHub 不提供 shell 访问权限。

我正在使用 oh-my-zsh FWIW。为什么会发生这种情况?我也重新启动了我的 mac。但该文件似乎仍无法识别

git ssh port
1个回答
16
投票

你写道:

 Host github.com
   HostName ssh.github.com
   Port 443

但没用过:

 ssh -T [email protected]

你需要

 ssh -T [email protected]

使用您定义的

github.com
主机。


或者,添加

ssh.github.com
作为另一个名称来匹配:

 Host github.com ssh.github.com
   HostName ssh.github.com
   Port 443
© www.soinside.com 2019 - 2024. All rights reserved.