Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 07-09-2010, 04:09 PM   #1
LQ Newbie
Registered: Jul 2010
Posts: 1

Rep: Reputation: 0
Unhappy 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
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


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.

Old 07-10-2010, 01:58 AM   #2
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
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

user foomaster
ProxyCommand ssh nc 22
this command uses nc to connect to server3 from server2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh tunnel port forwarding andycol Linux - Server 2 03-18-2010 08:01 AM
[SOLVED] Firewall restrictions on sock5 tunnel forwarding (through ssh) investor_me Linux - Networking 3 09-09-2009 08:29 PM
Forwarding Yahoo IM using iptables after SSH tunnel kenevel Linux - Security 2 04-07-2009 06:31 AM
ssh tunnel / port forwarding Q FrayAdjacent Linux - Networking 2 07-05-2005 04:37 PM
SSH tunnel or Iptables forwarding jatro Linux - Networking 5 06-15-2005 04:07 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration