使用ssh克隆Git时卡住了

4

我最近安装了Fedora 26,并使用github设置了SSH密钥。

我可以通过SSH进行身份验证并推送、拉取和克隆。

但现在每当我执行克隆命令时,git就会在Cloning into 'Blog'...处挂起。

以下是ssh -Tvv git@github.com的输出:

OpenSSH_7.5p1, OpenSSL 1.1.0f-fips  25 May 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to github.com [192.30.255.113] port 22.

程序停止响应,没有错误消息和输出。

这是我的ssh-config文件。

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
#
# To modify the system-wide ssh configuration, create a  *.conf  file under
#  /etc/ssh/ssh_config.d/  which will be automatically included below
Include /etc/ssh/ssh_config.d/*.conf

我该如何解决这个问题?
顺便提一下,如果需要额外的信息,请在评论中留言。

这是在克隆任何存储库时发生的,还是在克隆特定存储库时发生的? - user7346816
这适用于所有存储库和所有 git 功能(克隆、推送、拉取)。 - Aswin Mohan
你有没有任何与/etc/ssh/ssh_config.d/*.conf匹配的文件?其中有关于GitHub的内容吗? - user4121362
我刚刚测试了一下,不仅是GitHub的问题。我无法通过ssh连接到任何网站。它只是在连接时挂起,过一段时间后显示连接超时。 - Aswin Mohan
我可以很好地执行ssh localhost - Aswin Mohan
显示剩余2条评论
1个回答

1

在 GitHub 支持页面的某个角落里,我苦苦寻找了一段时间,最终找到了一个帮助页面:

https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

原来我的工作场所有防火墙/端口保护的恰到好处的魔法组合,可以“几乎”允许常规的Git SSH访问GitHub,也就是说,它偶尔能够工作,但不可靠。 ;-b
通过在我的$HOME/.ssh/config文件中使用这个咒语,即使用SSH Over HTTPS,我突然间能够通过我的GitHub SSH密钥从命令行访问我的GitHub存储库:
主机 github.com
User git

Hostname ssh.github.com

Port 443

PreferredAuthentications publickey

IdentityFile /home/XXX/.ssh/github_id_rsa

TCPKeepAlive yes     # not sure if truly needed

IdentitiesOnly yes   # not sure if truly needed

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接