There are 3 computers:
- local machine (osx)
- server1 (centos 7 at data center port 22 open)
- server2 (centos 7 closed behind nat)
server2 maintains a reverse tunnel to server1 on port 2222. Running ssh localhost -p 2222
on server1 goes directly to the command line of server2
What is the best way to set up a tunnel from the local machine through server1 to server2? For instance it is possible to initiate a tunnel from localhost to server1 using ssh -D 5000 -N root@server1
.
How to make the extra hop and get the tunnel go all the way through from localhost to server1 to server2? I tried this kind of thing ssh -L 5000:localhost:5000 root@server1 ssh -L 5000:server2:2222 -N root@localhost
but it didn't work
e.g. localhost -5000-> server1 -2222-> server2