简体   繁体   English

使用 SSH 从跳机访问 git 服务器

[英]Access a git server using SSH from a hop machine

I have 3 machines labeled 1, 2 and 3 respectively我有 3 台机器分别标记为 1、2 和 3

  1. My development machine that does all the heavylifting (Windows / Have admin access)我的开发机器完成所有繁重的工作(Windows / 具有管理员访问权限)
  2. My work laptop that has vpn access to the company network (Windows / Don't have admin access)我的工作笔记本电脑可以通过 vpn 访问公司网络(Windows / 没有管理员访问权限)
  3. A company development server that I have setup with git (Ubuntu / Have admin access)我使用 git 设置的公司开发服务器(Ubuntu / 具有管理员访问权限)

I basically want to be able to push our repositories from machine 1 into machine 3 then commit directly.我基本上希望能够将我们的存储库从机器 1 推送到机器 3 然后直接提交。 I can use SSH to do this from machine 2 to 3 using the company vpn.我可以使用 SSH 从机器 2 到 3 使用公司 vpn 执行此操作。 However, machine 1 and 2 are on the same physical network, so surely I can setup some kind of routing from machine 1->2->(through vpn)3.但是,机器 1 和 2 在同一个物理网络上,所以我当然可以从机器 1->2->(通过 vpn)3 设置某种路由。

(The alternative to this is that I do development on the crummy laptop (machine 2) and have the machine sent away for a while to have the software I need installed on it) (替代方法是我在破旧的笔记本电脑(机器 2)上进行开发,然后将机器送走一段时间以在其上安装我需要的软件)

I've looked at reverse SSH tunneling but I'm not quite sure that is what I need to do.我看过反向 SSH 隧道,但我不太确定这是我需要做的。 I'm not very network savvy, more into the software side of things, so any advice is appreciated!我不是很精通网络,更喜欢软件方面的东西,所以任何建议都值得赞赏!

I've tried somethign akin to the below, however I'm just gettong connection timed out so I must be going about this wrong.我已经尝试过类似于下面的东西,但是我只是连接超时,所以我必须解决这个错误。

ssh -L 3333:amelia.magee@{machine3localip}:22 amelia.magee@{machine2localip}

You should not specify credentials when describing the tunnel :描述隧道时不应指定凭据:

ssh -L 3333:{machine3localip}:22 {machine2localip}

I think you already did this, just mentionning : machine3localip would be the ip as seen by machine 2.我想你已经这样做了,只是提到: machine3localip将是机器 2 看到的 ip。

You should then try :然后你应该尝试:

ssh amelia.magee@localhost:3333

Remove amelia.magee@ after 3333: , it's not valid.删除amelia.magee@ 3333: ,无效。

ssh -L 3333:{machine3localip}:22 amelia.magee@{machine2localip}

Here is an excellent answer about ssh tunnel: https://unix.stackexchange.com/a/118650/162326这是关于 ssh 隧道的一个很好的答案: https : //unix.stackexchange.com/a/118650/162326

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

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