ssh -vvvT git@github.com有时会在调试1时卡住:正在连接到github.com端口22

8yoxcaq7  于 2022-11-20  发布在  Git
关注(0)|答案(2)|浏览(238)

当我尝试通过ssh连接github时,有时会卡在debug1: Connecting to github.com port 22.上。当我尝试通过git push连接github时,也会发生同样的情况。问题是有时我会得到连接,但很少。可能30次尝试中我只得到一次。
我尝试了不同的端口,没有改善。我检查了git配置,似乎很好。
我的.ssh/配置

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

我的etc/ssh/配置

# lots of uncommented lines... then line 48:    
Host *
  SendEnv LANG LC_*

ssh -vvvT git@github.com的输出

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/alucca/.ssh/config
debug1: /Users/alucca/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to github.com port 22.

谢谢你的建议。

lvmkulzt

lvmkulzt1#

假设您无法使用HTTP URL,您可以尝试看看using Using SSH over the HTTPS port是否是您的情况的可能解决方法。

ssh -T -p 443 git@ssh.github.com

如果这样做有效,您可以在~/.ssh/config中添加

Host github.com
  Hostname ssh.github.com
  Port 443
slmsl1lt

slmsl1lt2#

问题

在我的案例中,我也犯了同样的错误:运行ssh -T git@github.com时在以下位置卡住:

debug1: Connecting to github.com port 22.

我想这可能是OpenSSH中的一个bug,但我有另一台机器,它有相同的macOS版本和OpenSSH,没有这个问题。

原因

我当时使用的是小飞贼,由于某种原因,它阻止了到GithubIdeComm的SSH流量。我进入小飞贼并启用了它。

  • 可惜的是,小飞贼虽然开启了警戒状态,却并没有提醒我,而是直接屏蔽了。

这里有一个类似的www.example.com的截图gitlab.com。我也必须为gitlab.com修复它。

溶液

单击Little Snitch中的勾号,如屏幕截图所示。

相关问题