Sponsored Content
Top Forums Shell Programming and Scripting SSH Tunnel Forwarding with no shell Post 302436215 by Scriptingglitch on Friday 9th of July 2010 04:28:15 PM
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...
 

6 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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
HTTP::Server::Simple::Static(3pm)			User Contributed Perl Documentation			 HTTP::Server::Simple::Static(3pm)

NAME
HTTP::Server::Simple::Static - Serve static files with HTTP::Server::Simple VERSION
This documentation refers to HTTP::Server::Simple::Static version 0.07 SYNOPSIS
package MyServer; use base qw(HTTP::Server::Simple::CGI); use HTTP::Server::Simple::Static; sub handle_request { my ( $self, $cgi ) = @_; return $self->serve_static( $cgi, $webroot ); } package main; my $server = MyServer->new(); $server->run(); DESCRIPTION
this mixin adds a method to serve static files from your HTTP::Server::Simple subclass. SUBROUTINES
/METHODS serve_static Takes a base directory and a web path, and tries to serve a static file. Returns 0 if the file does not exist, returns 1 on success. BUGS AND LIMITATIONS
Bugs or wishlist requests should be submitted via http://rt.cpan.org/ SEE ALSO
AUTHOR
Stephen Quinney "sjq-perl@jadevine.org.uk" Thanks to Marcus Ramberg "marcus@thefeed.no" and Simon Cozens for initial implementation. LICENSE AND COPYRIGHT
Copyright 2006 - 2008. Stephen Quinney "sjq-perl@jadevine.org.uk" You may distribute this code under the same terms as Perl itself. perl v5.14.2 2012-06-30 HTTP::Server::Simple::Static(3pm)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy