Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's the scenario:

                   ssh  +------------+
                  +---->|  Server 2  |
 +------------+   |     +------------+
 |  Server 1  +---+
 +------------+   |     +------------+
                  +---->|  Server 3  |
                   ssh  +------------+

I have SSH access from Server 1 to both Server 2 and Server 3 (but not from Server 2 to Server 3 nor the other way around).

I want to transfer a rather large file from 2 to 3 and would like to know what's the fastest way to do so by having 1 acting as the orchestrator.

UPDATE: I do have connectivity between the two servers, just not SSH credentials from/to the servers.

share|improve this question
up vote 5 down vote accepted

you can do the transfer directly between the 2 servers:

on the server you want to transfer to, start nc in listen mode on some random port:

ssh dst-server 'exec 1>/tmp/bah; nc -l -p 34001'

on the server you want to download from, transfer with nc in client mode. you can use compression to, just create a gzip pipe:

ssh source-server 'nc dst-server 34001 < ./bah'

you'll find your file in /tmp/bah

share|improve this answer
Not if server2 can't make a connection to server3, which is how I read the question. @kolrie explicitly says "by having 1 acting as the intermediary." – mfinni May 11 '12 at 19:54
I do have connectivity between the two servers. Added a clarification to the question. – kolrie May 11 '12 at 19:57
I read "ssh access" – sysfault May 11 '12 at 19:57
Also changed the word from intermediary to orchestrator, to make it fair. – kolrie May 11 '12 at 19:57

You could use 'scp':

On Server 1 do something like this:

scp  user1@server2:/path/filename user3@server3:/path 

More info with man scp.

share|improve this answer
this will tranfer the file on the middle server and then upload it to destination server. kind of ... expensive, right? – sysfault May 11 '12 at 19:50
Thanks a lot for your input. It seems my original question was misleading. I can access Server 2 from Server 1 and vice-versa. Just can't SSH connect between the two. – kolrie May 11 '12 at 19:58
@malfaux: Yes, it's doubling the transfer. But in most cases, it's just much more quicker than your approach, which I would do for large files or over a slow link. – Sven May 11 '12 at 20:32
@SvenW oh? how is transferring 2x$N GB of data over 2 different links "much more quicker" than transferring $N GB of data over the same link? i'd say it's much more costly, time and money. unless you know he has fiber between s1 and s2 and s1 and s3 and a dial-up link between s2 and s3. is that your argument? I'm just curious what are you thinking. cheers! – sysfault May 12 '12 at 8:19
@malfaux: In most cases with a few GB of transfer, the copying would be done with my version of the command before I logged into two computers to initiate a transfer via nc. This is moot anyway, because in my networks, when a machine can talk to another via nc, it can talk to it via ssh. – Sven May 12 '12 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.