在我的新工作电脑上安装了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连接。
此答案 中的任何修复方法都没有改变任何东西。(我在Windows上)
我注意到如果我删除了
~/.ssh
文件夹中的密钥,我会得到同样的错误,这使我认为这是一个密钥问题而不是网络问题。如何确保git正在使用正确的密钥?我尝试了
ssh-keygen -lf ~/.ssh/id_rsa -E md5
来查看指纹是否与gitlab上的指纹匹配(它是),但这只给出了文件夹中的指纹,而不一定是git使用的指纹。不过,Git-gui Help>Show SSH Key
可以正确显示我的密钥。