5

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.

2 Answers 2

5

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

4
  • 1
    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, 2012 at 19:54
  • I do have connectivity between the two servers. Added a clarification to the question.
    – kolrie
    May 11, 2012 at 19:57
  • I read "ssh access"
    – user237419
    May 11, 2012 at 19:57
  • Also changed the word from intermediary to orchestrator, to make it fair.
    – kolrie
    May 11, 2012 at 19:57
6

You could use 'scp':

On Server 1 do something like this:

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

More info with man scp.

5
  • this will tranfer the file on the middle server and then upload it to destination server. kind of ... expensive, right?
    – user237419
    May 11, 2012 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, 2012 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, 2012 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!
    – user237419
    May 12, 2012 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, 2012 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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