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.