SSH Tunnel Forwarding with no shell
Hi Experts,
I am trying to have the SSH tunnel Remote forwarding command in a shell script. I should be able to do 2 tasks, but unable to get that going. 1) I have 3 servers Server 1, Server 2, Server 3. I have my Database running on Server 1 and my script running on Server 2 which should be able to do port forwarding from Server 1 to Server 3. so for example on Server 2 ssh -i $ssh_key -R 9000:Server1:3333 root@Server2. I need to be able to stick this in a shell script something like getTunnel() { echo "HOST" echo "Creating HTTP Tunnel to Instance in the background" ssh -T -t -i $ssh_key -R 9000:Server1:3333 root@$HOST & <<EOF mysqladmin -u root -S /tmp/mysql-DB.sock start-slave EOF echo "Tunnel Create" } 2) In this second task not be able to get the shell prompt of the Server 3 but pass some commands to execute on the remote server. Can someone please be able to help me through with this. That should be very helpful. I have been stuck with this problem for many days with out a solution. Thanks. |
There is some thing known as nc for such situation in case of server2.
in this situtation it is common to setup the users .ssh/config file to use an ssh proxy so they can just ssh instead of sshing to server2 and then server3 Code:
Host server2.yourwork.com |
All times are GMT -5. The time now is 06:20 PM. |