简体   繁体   English

通过SSH代理主机的git clone问题

[英]git clone issues via an SSH proxied host

I have a setup where we are using a bastion/jump-host to access a remote server and I'm having issues doing my git clone. 我有一个设置,我们在其中使用堡垒/跳转主机访问远程服务器,并且在执行git clone时遇到问题。

In my git config i have the followings setup: 在我的git配置中,我有以下设置:

Local .ssh/config 本地.ssh / config

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

Remote .ssh/config 远程.ssh / config

LogLevel DEBUG1

So if I do ssh remoteDevel.remotedomain.org it will route me via this proxy host and all is good. 因此,如果我使用ssh remoteDevel.remotedomain.org ,它将通过此​​代理主机路由我,一切都很好。

Case 1 - Clone on the Remote side 情况1-远端复制

#Log into remote machine via SSH
ssh remoteDevel

#Clone repo
git clone ssh://git@stash.remotedomain.org:7999/mirror/disjockey.git

What I noticed is the SSH debug "stuff" prints out this line 我注意到的是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

This looks like to me like its making a proxy into the Atlassian Stash server to pull down the git repo (good) 在我看来,这就像它成为Atlassian Stash服务器的代理以拉下git repo(很好)

Case 2 - Local via Proxy 情况2-通过代理本地

When I try the same command locally things go awry 当我在本地尝试相同的命令时,出现问题

git clone ssh://git@stash.remotedomain.org:7999/mirror/disjockey.git

First I see it tries to go via the jumpiest 首先,我看到它试图通过最跳越

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:

So? 所以?

Well obviously it isn't working as I hoped. 好吧,显然它没有按我希望的那样工作。 From what I can tell my proxy command is likely off as it looks like its trying to proxy into stash:22 when I run it locally and into stash:7999 when I run it remotely. 据我所知,代理命令可能已关闭,因为它似乎在本地运行时尝试代理到stash:22 ,而在远程运行时代理到stash:7999

I tried to change my proxy command to: 我试图将代理命令更改为:

ProxyCommand ssh -l username jumphost nc %h 7999

But that seems to never log in correctly. 但这似乎永远无法正确登录。 Not exactly sure what to do here but I'm assuming its probably something simple that I'm missing? 不完全确定该怎么做,但我假设我可能缺少一些简单的东西?

Updates SocksProxy 更新SocksProxy

I found a way to make things work - but I'm confused as to how this actually helps things 我找到了一种使事情起作用的方法-但我对这实际上如何帮助事情感到困惑

First I create a Socks Proxy with : ssh -D 1080 machine.remotedomain.org 首先,我使用以下命令创建一个袜子代理: ssh -D 1080 machine.remotedomain.org

Then I edit my .ssh/config 然后我编辑我的.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

And then my git clone will work, however, this is problematic because i had to comment out the lines i needed in the 1st place to create my socks tunnel. 然后我的git clone将起作用,但是,这是有问题的,因为我必须注释掉第一处创建袜子通道所需的行。

We got things working! 我们正在努力! Here was the .ssh/config that did the trick. 这是完成问题的.ssh/config

Host remote connects to the machine gen1 on the remote network. 远程主机连接到远程网络上的计算机gen1

Connecting to: stash.remotedomain.org basically does a 2nd proxy on top of the remote one, and proxies into port 7999 which is what the git server (atlassian stash) is running. 连接到: stash.remotedomain.org基本上在远程代理的顶部进行第二个代理,并代理到端口7999 ,即git服务器(atlassian stash)正在运行的端口。

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

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

So when I do: git clone ssh://git@stash.remotedomain.org:7999/mirror/disjockey.git everything works!! 所以当我这样做时: git clone ssh://git@stash.remotedomain.org:7999/mirror/disjockey.git一切正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM