带有双SSH的Git [英] Git with double SSH
问题描述
我有:本地,服务器1,服务器2.
I have: local, server1, server2.
我在server2上有Git存储库.但是我无法连接它. 我可以使用SSH连接到server1,然后使用SSH连接到server2.
I have Git repository on server2. But I can't connect with it. I can connect to server1 with SSH and then connect to server2 with SSH.
如何使用双SSH将提交推送到server2?有可能吗?
How can I push commits to server2 with double SSH? Is it possible?
推荐答案
一种解决方案是在网关主机(server1)上准备 SSH隧道,并在本地端使用Git(您可能需要使用.ssh/options
配置端口).
One solution is to prepare SSH tunnel on gateway host (server1), and use Git with the local end (you might need to use .ssh/options
to configure port).
Another is a pure Git solution to use ext::
remote helper with double SSH (you better set up password-less public key based authentication at least on gateway, or you would have to give passwords twice). For example:
local ~$ git clone \
"ext::ssh -t user@server1 ssh server2 %S 'repo'" repo
Cloning into 'repo'...
Checking connectivity... done.
此处%S
将由Git扩展为适当服务的全名,git-upload-pack
用于获取,而git-receive-pack
用于推送.如果登录到内部主机使用交互式身份验证(例如密码),则需要-t
选项.
Here %S
will be expanded by Git into full name of appropriate service, git-upload-pack
for fetching and git-receive-pack
for push. The -t
option is needed if logging to internal host uses interactive authentication (e.g. password).
请注意,您需要提供要下载到的名称或目录,作为git clone
命令的最后一个参数(此处为repo
)到此处生成的存储库;否则,Git将使用命令(ssh ...
)作为名称.
Note that you need to give the name or directory to download to as the last parameter to git clone
command (repo
here) to the resulting repository here; otherwise Git would use the command (ssh ...
) as name.
然后,您将可以通过名称"origin"来获取并推送到存储库.
Then you would be able to fetch and push to repository by the name "origin".
这篇关于带有双SSH的Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!