help with ssh tunneling
Hi,
my problem is pretty simple and I am sure that some of you can help me with it. I want to make a script to connect via ssh to a remote host not reachable directly from my computer. However I have ssh access to a computer with ssh access to the target host.
Schematically:
host1: my PC
host2: A host reachable via ssh from host1
host3: A host reachable via ssh from host2 but not from host1
¿How connect host1 to host3 vis ssh? The solution you may think of is a ssh tunnel. I know how to set up this tunnel from the command line but not from within a script, and this is why I am asking for help.
From the command line (from host1):
1) [user@host1 ~] ssh -L 9999:host3:22 user@host2
After entering my password a prompt
[user@host2 ~]$
appears.
2) Now, in another terminal I execute
[user@host1 ~] ssh -p 9999 localhost
and, after entering the user's password I can enter host3.
The problem is to arrange this in a script. The reason being that the ssh tunnel set up in step 1) is in the foreground. If I could to put the ssh connection in the background perhaps I could get what I want.
Rafael Gallego
|