Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过SSH代理主机的git克隆问题_Git_Ssh_Proxy - Fatal编程技术网

通过SSH代理主机的git克隆问题

通过SSH代理主机的git克隆问题,git,ssh,proxy,Git,Ssh,Proxy,我有一个设置,我们使用堡垒/跳转主机来访问远程服务器,我在进行git克隆时遇到问题 在我的git配置中,我有以下设置: Local.ssh/config Remote.ssh/config 因此,如果我执行ssh remoteDevel.remotedomain.org,它将通过这个代理主机路由我,一切都很好 案例1-远程端的克隆 我注意到SSH调试“东西”打印出了这行代码 Initialized empty Git repository in /home/USER/disjockey/.git

我有一个设置,我们使用堡垒/跳转主机来访问远程服务器,我在进行git克隆时遇到问题

在我的git配置中,我有以下设置:

Local.ssh/config Remote.ssh/config 因此,如果我执行
ssh remoteDevel.remotedomain.org
,它将通过这个代理主机路由我,一切都很好

案例1-远程端的克隆 我注意到SSH调试“东西”打印出了这行代码

Initialized empty Git repository in /home/USER/disjockey/.git/
debug1: Executing proxy command: exec /usr/bin/sss_ssh_knownhostsproxy -p 7999 stash.remotedomain.org
在我看来,这就像是在Atlassian隐藏服务器中制作一个代理来拉下git回购(很好)

案例2-通过代理进行本地 当我在本地尝试相同的命令时,会出现问题

git clone ssh://git@stash.remotedomain.org:7999/mirror/disjockey.git
首先我看到它试图通过最跳跃的

debug1: Executing proxy command: exec ssh -l USERNAME jumphost nc stash.remotedomain.org 22
....
#Lots of junk
....
debug1: Next authentication method: password
git@stash.remotedomain.org's password:
所以 很明显,它没有像我希望的那样工作。据我所知,我的proxy命令可能已关闭,因为当我在本地运行它时,它似乎试图代理到
stash:22
,而当我远程运行它时,它又试图代理到
stash:7999

我试图将代理命令更改为:

ProxyCommand ssh-l用户名jumphost nc%h 7999

但这似乎永远不会正确登录。不太清楚该怎么做,但我想这可能是我错过的简单的东西吧

更新SocksProxy 我找到了一种让事情运转起来的方法——但我不知道这到底是如何帮助事情的

首先,我创建了一个Socks代理:
ssh-d1080 machine.remotedomain.org

然后我编辑我的
.ssh/config

#Host *.remotedomain.org
#   ProxyCommand ssh -l username jumphost nc %h 22`
#   LogLevel DEBUG1

Host stash.remotedomain.org
    User git
    ProxyCommand nc -x localhost:1080 %h %p

然后我的
git克隆就可以工作了,但是,这是有问题的,因为我必须注释掉创建socks隧道所需的第一行代码

我们有办法了!下面是实现这一技巧的
.ssh/config

主机remote连接到远程网络上的机器
gen1

连接到:stash.remotedomain.org基本上在remote上执行第二个代理,并代理到git服务器(atlassian stash)正在运行的端口
7999

Host remote
    HostName gen1
    ProxyCommand ssh -l username jumphost nc %h %p

Host stash.remotedomain.org
    ProxyCommand ssh remote nc stash 7999
所以当我这样做时:
git clonessh://git@stash.remotedomain.org:7999/mirror/disjockey.git

一切正常

有什么原因不能在PROXY命令中使用
%p
而不是硬编码端口号?
debug1: Executing proxy command: exec ssh -l USERNAME jumphost nc stash.remotedomain.org 22
....
#Lots of junk
....
debug1: Next authentication method: password
git@stash.remotedomain.org's password:
#Host *.remotedomain.org
#   ProxyCommand ssh -l username jumphost nc %h 22`
#   LogLevel DEBUG1

Host stash.remotedomain.org
    User git
    ProxyCommand nc -x localhost:1080 %h %p
Host remote
    HostName gen1
    ProxyCommand ssh -l username jumphost nc %h %p

Host stash.remotedomain.org
    ProxyCommand ssh remote nc stash 7999