【发布时间】:2022-02-17 17:53:11
【问题描述】:
在我的新工作计算机上安装 git,生成我的 ssh 密钥并将其添加到 gitlab 后,我试图克隆一个项目,但我收到以下错误:
ssh: connect to host <private-domain>.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我还尝试了使用详细选项测试 ssh 连接的命令,我得到了这个:
$ ssh -Tvvv appgit@<private_domain>.com
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/h/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/h/.ssh/known_hosts2'
debug2: resolving "<private_domain>.com" port 22
debug3: resolve_host: lookup <private_domain>.com:22
debug3: ssh_connect_direct: entering
debug1: Connecting to <private_domain>.com [<serv.ip.add.ress>] port 22.
debug3: set_sock_tos: set socket 4 IP_TOS 0x48
debug1: connect to address <serv.ip.add.ress> port 22: Connection timed out
ssh: connect to host <private_domain>.com port 22: Connection timed out
我知道域存在,ping <private-domain>.com 有效。我不认为这是代理问题,因为我没有使用 http 或 https 连接。
this answer 中的修复都没有改变任何东西。 (我在 Windows 上)
我注意到,如果我删除 ~/.ssh 文件夹中的密钥,我会收到同样的错误,这让我认为这是一个密钥问题,而不是网络问题。如何确定 git 使用的是正确的密钥?
我已经尝试ssh-keygen -lf ~/.ssh/id_rsa -E md5 来查看指纹是否与 gitlab 上的指纹匹配(确实如此),但这只会给我文件夹中的指纹,不一定是 git 使用的指纹。 Git-gui Help>Show SSH Key 确实正确显示了我的密钥。
【问题讨论】:
-
"timed out" 错误通常意味着您正在拨打 Internet 电话并恢复了死寂:它没有发出忙音信号,您没有收到“boo-bah-beep!the您拨打的号码不在服务区”,没有人打招呼,只是……什么都没有。可能你的手机坏了。也许电线被切断了。有很多可能性。
-
ping 对相关名称有效这一事实很有希望。使用您必须使用的任何网络诊断工具来跟踪 ssh 数据包。观察双方(你的一端,服务器主机)。然后一路走到中间,看看哪里出了问题。
标签: git ssh gitlab connection-timeout