SSH Tunnel Forwarding with no shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH Tunnel Forwarding with no shell
# 1  
Old 07-09-2010
Data 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

Code:
ssh -i $ssh_key -R 9000:Server1:3333 root@Server2.

I need to be able to stick this in a shell script something like
Code:
 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.

Last edited by pludi; 07-09-2010 at 05:48 PM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Tunnel using SSH

I am not clear with the part of concept of Tunneling using ssh. ssh -f -N -L 1029 192.168.1.47:25 james@192.168.1.47 I found out that above code works for me . but didn't quite well understood how ti works and need to ask you guys some questions. since we are using tunnel through ssh ... (2 Replies)
Discussion started by: lobsang
2 Replies

2. Solaris

Tunnel X over ssh for 11.3

Hello Solaris experts: Trying to bring the 11.3 gdm screen over ssh to a Linux Box: I did the following: 1. made chanes to /etc/ssh/sshd_config & bounced ssh daemon: # X11 tunneling options X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes 2. From the remote Linux box: ... (6 Replies)
Discussion started by: delphys
6 Replies

3. Red Hat

X11 forwarding through a tunnel

Is it possible to launch an X11 application and have it use an X11 server on the other side of a bastion host? Specifically, here's my setup: my laptop ------------- bastion -------------- remote host I have putty installed on my laptop. The bastion is rhel 6.5 and the remote host is... (1 Reply)
Discussion started by: tsreyb
1 Replies

4. IP Networking

Help with SSH tunnel?

I have a Java web app on machine (X) that needs to talk to an LDAP server (Y) on :636, but the LDAP server is only accessible on a particular network. I can login to a machine (Z) on that network from X, and this machine can talk to the LDAP server on :636. How can I tunnel so that X can... (2 Replies)
Discussion started by: spacegoose
2 Replies

5. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

6. Cybersecurity

ssh X-forwarding and remote forwarding behind proxy

Hi, from my workplace we use a proxy to connect to the outside world, including external ssh servers. The problem is that the server is seeing the connection coming from the proxy and knows nothing about the client behind it. The ssh connection itself works fine, but x-forwarding does not work as... (1 Reply)
Discussion started by: vampirodolce
1 Replies
Login or Register to Ask a Question