ssh from server 1 over server 2 to server 3


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh from server 1 over server 2 to server 3
# 1  
Old 11-16-2010
ssh from server 1 over server 2 to server 3

in fact i want to do something like

ssh serv01 "gunzip < zipped.tar.file.tar.gz" | ssh serv03 "tar xvfn -"

while standing on server 2

The point is that server 1 and 3 are on different networks and can contact each other directly and that I do not have write permissons on server 2

Server 2 can connect to both servers

Anyone an idea how to tackle this one ?

---------- Post updated at 01:25 PM ---------- Previous update was at 01:25 PM ----------

oh by the way, this constuctions just keeps hanging
# 2  
Old 11-16-2010
Trust relationship between the servers?
# 3  
Old 11-16-2010
the servers are on different networks that's the reason for this setup.
s1 is on an internal network and s3 is behind a firewall
the only way to go from 1 to 3 is over 2
but, as already said, I can NOT write on 2
# 4  
Old 11-16-2010
Hi, maybe you could tunnel ssh from serv01 to serv03 via serv02.

This is the script to run on serv01 to do the job.

bash code:
  1. # Open ssh tunnel localhost:1234 to serv03 via serv02 . . .
  2. ssh -NfL 1234:serv03:22 serv02
  3.  
  4. # Check if it's working . . .
  5. ssh -p 1234 localhost "uname"
  6.  
  7. # Now do the job
  8. gunzip <zipped.tar.file.tar.gz | ssh -p 1234 localhost "tar xvfn  -"

Last edited by Chirel; 11-16-2010 at 08:04 PM..
This User Gave Thanks to Chirel For This Post:
# 5  
Old 11-17-2010
ok, great this works fine
can you give some more explanation so I understand better what I'm doing ?
what is 1234 ? can I personalize this ?
what is 22 ?

---------- Post updated at 09:57 AM ---------- Previous update was at 09:53 AM ----------

and, how long will this tunnel last ?
untill I quit my session or do I have to kill it myself ?
# 6  
Old 11-17-2010
Sure,

  • 1234 is a random port i choosed you can choose any other of your choice.
  • 22 is the standard ssh port so the communication between serv02 => serv03 use the ssh port, this is a choice because we want to connect to the ssh deamon on serv03.
  • The tunnel will last as long as the process is running, you have to kill it.
There is a little tricks to know. This kind of ssh usage will add a localhost entry to the .ssh/know_hosts file. You should have to remove this line with localhost as the first step, unless you using the ssh tunnel always to talk with the same host.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Is it mandatory or not to stop/start Applcation server ehen Restarting Database Server?

Good afternoon I need your help please. There is a Mantenance Windos which needs to Restart de Database Server 192.x.x.97 to set up some configuration Is it mandatory or not to stop/start Applcation server that runs in 192.x.x.95 ? Is it mandatory or not to stop/start apache and Tomcat?... (3 Replies)
Discussion started by: alexcol
3 Replies

2. AIX

How to ssh from an AIX OS server to a Fabric OS server without password?

Hi I'd like to ssh from an AIX OS server ( v5.3) to a Fabric OS server ( v6.1.2 ) without password. I tried using dsa or rsa keys but it didn't work, the aix server still asked for the password. Somebody help, please :(:(:( (8 Replies)
Discussion started by: bobochacha29
8 Replies

3. Shell Programming and Scripting

Multi server access through remote server using ssh

Team, Presently I have 5 ip address kept in ip_abc1 file, for each of the ip address listed, i need to login on each ipaddress one at a time and login as below for that specific ip address ssh -p 8101 karaf@<ip.address_for the specific ip address as logged in> password features:list... (4 Replies)
Discussion started by: whizkidash
4 Replies

4. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

5. Shell Programming and Scripting

Connect to server-1 from server-2 and get a file from server-1

I need to connect to a ftp server-1 from linux server-2 and copy/get a file from server-1 which follows a name pattern of FILENAME* (located on the root directory) and copy on a directory on server-2. Later, I have to use this file for ETL loading... For this I tried using as below /usr/bin/ftp... (8 Replies)
Discussion started by: dhruuv369
8 Replies

6. Shell Programming and Scripting

Ssh to get files from server A and zip in server B

Hi, I have read & write access in Unix box A and read access in Unix box B. I want a folder to be zipped from box B and sftp-ed in box A. Is there a remote scripting to achieve this? (2 Replies)
Discussion started by: Prasannag87
2 Replies

7. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

8. Shell Programming and Scripting

KSH fetching files from server A onto server B and putting on server C

Dear Friends, Sorry for this basic request. But I just started learning Ksh recently and still I am a newbie in this field. Q: I have files on one server and the date format is 20121001000009_224625.in which has year (yyyy) month (mm) and date (dd). I have these files on server A. The task... (8 Replies)
Discussion started by: BrownBob
8 Replies

9. Programming

Problem with Perl script after moving from a Windows/Apache Server to a UNIX server.

I have a Perl script that worked fine before moving it to justhost.com. It was on a Windows/Apache server. Just host is using UNIX. Other Perl scripts on other sites that were also moved work fine so I know Perl is functioning. The script is called cwrmail.pl and is located in my cgi-bin. When I... (9 Replies)
Discussion started by: BigBobbyB
9 Replies

10. Solaris

NFS write failed for server.....error 11 (RPC: Server can't decode arguments)

Hello! I have a Linux nfs server (called server100 below) with a export nfs. My problem is that the Solaris client (called client100 below) doesn't seems to like it. In the Solaris syslog I got following messages (and after a while the solaris client behave liked its hanged/to buzy). Also see... (3 Replies)
Discussion started by: sap4ever
3 Replies
Login or Register to Ask a Question