0

I am trying to create a tunnel directly with ssh command. My scenario works well when I do following configuration

host: A pass:** Tunnel Section in Putty : 6001:HostXX:22 Open this session now

login with 127.0.0.1 port 6001 and username/password for HOSTXX Tunnel Section in Putty : 20333:DBHOST:54666

This work well when I start putty session individually for both sessions.

I am trying to find a solution where I could do this tunneling directly using one ssh command.

I tried following but did not work.

ssh -f HostA -l username -L 6001:10.54.172.68:22 \ ssh -p 6001 -N 127.0.0.1 -l username1 -i username1.pem -L 20333:dbhost:54666

ssh -fN HostA -l username -L 6001:10.54.172.68:22 \ ssh -fN -p 6001 -N 127.0.0.1 -l username1 -i username1.pem -L 20333:dbhost:54666

I also tried from cmd running these commands individually but not helping me. Please suggest any solution

Nmath
  • 12,333

1 Answers1

0

Tunneling works better as a proxy. All you should have to do to create the tunnel to ssh to servers on the other side of the tunnel is:

Create tunnel:

ssh -qCfND <PORT> username@tunnelserver

Where <PORT> is any port you want to assign. 6001 would work fine. The switches are -q for Quiet Mode. C for Compression. f for ssh to go to the background. N for just forwarding the port. D for port binding.

Then to ssh to any server on the other side it is:

ssh -o "StrictHostKeyChecking no" -o ProxyCommand='nc -X 5 -x 127.0.0.1:6001 %h %p' username@remoteserver

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183