简体   繁体   中英

how to configure system to use git via an ssh reverse tunnel / proxy?

Environment: My localhost has access to my VPN. My remotehost needs to access the VPN via my localhost. I can only ssh from localhost to remotehost. I have setup a tunnel to access the shell on my remotehost.

I have ssh setup from localhost to remotehost using keys and without password prompt.

This allows me to run VNC from localhost to access my remotehost.

Problem: My remotehost has git repos which need to be updated, but via the localhost's VPN. ie when I perform on the remotehost a git pull command, it will access the VPN git repository via the tunnel created from localhost.

I have read about ssh -R and ssh .config having a ProxyCommand, but putting it altogether is a mess.

You could use the RemoteForward option in your .ssh/config

HOST remoteHost
   hostname remotehost.somewhere.com
   user <username>
   RemoteForward 127.0.0.1:2022 <VPN-GitHost>:22

This publishes the port 22 from your VPN to your remoteHost but changes the port number to 2022.

On your remote host you can use that port via ssh (and also git) like

ssh myuser@localhost -p 2022

Or edit the .ssh/config on the remote host

HOST VPN-gitHost
   hostname localhost
   port 2022

Then your git pull should work without any modifications

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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