我的笔记本电脑上有一个本地存储库,其中已经有一个名为
origin
的遥控器。除了我的笔记本电脑和 origin
之外,还有第三台名为 remote1
的机器,我想将其作为另一个遥控器添加到我的本地存储库中。我在笔记本电脑上做的是
git remote add remote1
git remote set-url remote1 ssh://sshUser@remote1Address:path/to/.git
但是这样做时,命令
git push remote1 branchName
给出
ssh: connect to host remote1Address port 22: Connection timed out.
只能通过
ssh
访问远程 1
跳转代理。 Port 22
被关闭是在此使用跳转代理的主要原因
案件;这是我的
.ssh/config
Host jumpProxy
Hostname jumpProxyAddress
User jumpUser
Host remote1
Hostname remote1Address
User sshUser
ProxyJump jumpUser@jumpProxyAddress
所以我猜 问题的根源在于跳转代理根本没有被调用, 也就是说,
.ssh/config
根本没有被读取。您建议什么解决方案?
我发现你的
git remote set-url
声明有两处错误:
remote1
中为 ~/.ssh/config
定义了特定主机名以及代理和用户详细信息,但您并未使用它。ssh://
,那么 user@host
详细信息和存储库路径之间应该有一个斜杠(而不是冒号)。您应该能够通过一条语句解决这两个问题:
git remote set-url remote1 ssh://remote1/path/to/.git
。 (请注意,那里没有 user@
;它是在您的 ~/.ssh/config
中定义的。)