Where I am located, I don't have access into a specific ssh host (through GIT) and I want to know if its possible to tunnel into it through something like proxy (even though proxy doesn't work with ssh). Can I SSH into one host and connect into another through the previous one's tunnel? Or something similar?


1 Answer 1


If I understand the question correctly, you need something like the following

ssh -L 2222:host1:22 -L 2223:host2:22 -L 2224:host3:22 user@middlehost

This is a command that you run on your local machine. middlehost is the host you are able to log into from your local machine with ssh user@middlehost. host1, host2, host2, are machines that you would like to log into but cannot from your local machine, but you can from middlehost.

After you have run the above command you need to run the following on your localhost to, for example, log in to host2

ssh -p 2223 user2@localhost

port 2223 is automatically forwarded to middlehost, where the original command forwards it to port 22 of host2. From the PoV of host2 it is middlehost that is ssh-ing to it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .