Search code examples
sshputtyssh-tunnelcmder

Putty multihop tunnel replicate in bash


Im experiencing a problem replicate my putty ssh tunneling with Cmder bash (on windows machine).

1. I want to access web interface on port 7183 on server_2. To get there I have to go through jump_server first and and tunnel twice, as from the jump_server, only visible port is 22.

Steps with putty:
1. connect to jump_server with tunnel (L22 server_2:22) using username_1
2. connect to localhost with tunnel (L7183 localhost:7183) using username_2

After that, Im able to access the web interface when I type localhost:7183 into browser on my local machine.

Now Im trying to reproduce this in Cmder, but I havent been able to do that with one big command, nor 2 separate commands:

ssh -L 7183:localhost:7183 username_1@jump_server ssh -L 22:localhost:22 -N username_2@server_2 -vvv

This is only the last command I used as I tried interchanging ports and hosts without success.

2. Is the syntax different when I want to open port 12345 on my local machine and have it forwarded to port 21050 on server_2 or that would be remote tunneling?


Solution

  • Finally managed to achieve the 1. question with:

    1. ssh username_1@jump_server -L 22:server_2:22 -N -vvv
    2. ssh -L 7183:localhost:7183 username_2@localhost

    Now Im albe to access the web interface from server_2 on my localhost:7183