transferring files over two-hop SSH session

Barton Chittenden

I have a Linux box at work that I often log in to from home. The Linux box is on an internal network, but there's a box that spans both networks, so I can log in like so:

ssh -tA [email protected] ssh [email protected]

I have a couple of files sitting in ~/tmp that I would like to copy to my local machine. (let's call them ~/tmp/file1 ~/tmp/file2 and ~/tmp/file3 for the sake of argument)

I've seen something like this work:

ssh -tA [email protected] ssh [email protected] 'tar cf - ~/tmp/file*' | tar xf -

This would tar the files on the remote machine, send the result to stdout, then pipe the results to a local tar, which was unpacking data on local stdin.

Doesn't work:

On the remote machine, if I run

tar cf - tmp/file* | md5sum
f1b776364c10dfc20500f228399a7c63  -

From the local machine:

ssh -tA [email protected] ssh [email protected] 'tar cf - ~/tmp/file*' | md5sum
bc7436c9771ee2b4978ffd29b8b7ed36  -

I'm assuming that this is probably a byte ordering snafu across the network... I was eventually able to get around it by uuencoding the file, catting it across the network then uudecoding it locally... for some reason I couldn't get the syntax correct to be able to tar | uuencode on the remote side and uudecode | untar on the local side.

I'm looking for a good way of doing this all in one step; preferably something that I can wrap in a shell function.

Zoredache

Use the SSH ProxyCommand configuration option to in the configuration on your client. This allows you to make a direct connection to the destination.

Host remotebox
    ProxyCommand /usr/bin/ssh [email protected] "/bin/netcat -w 1 10.10.10.130 22"
    User username

scp remotebox:file local

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Transferring large (8 GB) files over ssh

From Dev

Jenkins transferring 0 files using publish over SSH plugin

From Dev

Transferring files over TCP with CopyTo()

From Dev

Python - Transferring session between two browsers

From Dev

Python - Transferring session between two browsers

From Dev

Transferring large files over TCP in Qt

From Dev

Transferring files over home network WiFi

From Dev

Run X clients over multi-hop ssh tunnel

From Dev

Run X clients over multi-hop ssh tunnel

From Dev

Editing files through multi-hop ssh in Sublime Text 3

From Dev

Logging in over ssh in a different session?

From Dev

Close VIM session over ssh

From Dev

stdin 'hop' over process?

From Dev

SSH proxy tunnel hop

From Dev

SSH proxy tunnel hop

From Dev

Encrypting/Decrypting(Using AES) Large files and transferring over HTTP

From Dev

C# transferring lots of small files over a network

From Dev

Script for transferring files over the internet via a Cron task

From Dev

Is there a speed difference between transferring files over FTP and Samba?

From Dev

Does transferring files over a local network use up internet bandwidth

From Dev

How to Find the Bottleneck when Transferring Files over WAN

From Dev

Transferring files from remote Mac SSH to school Linux Server

From Dev

In Python, how do I get user's remote IP (their last hop) if they're connected over SSH?

From Dev

Transferring Files between two EC2 Instances in the same region

From Dev

Transferring files between two remote servers that use different protocols

From Dev

sh startup files over ssh

From Dev

Remove a list of files over SSH

From Dev

SFTP over double server hop

From Dev

How to multi-hop ssh using connect to server under other locations in Files

Related Related

  1. 1

    Transferring large (8 GB) files over ssh

  2. 2

    Jenkins transferring 0 files using publish over SSH plugin

  3. 3

    Transferring files over TCP with CopyTo()

  4. 4

    Python - Transferring session between two browsers

  5. 5

    Python - Transferring session between two browsers

  6. 6

    Transferring large files over TCP in Qt

  7. 7

    Transferring files over home network WiFi

  8. 8

    Run X clients over multi-hop ssh tunnel

  9. 9

    Run X clients over multi-hop ssh tunnel

  10. 10

    Editing files through multi-hop ssh in Sublime Text 3

  11. 11

    Logging in over ssh in a different session?

  12. 12

    Close VIM session over ssh

  13. 13

    stdin 'hop' over process?

  14. 14

    SSH proxy tunnel hop

  15. 15

    SSH proxy tunnel hop

  16. 16

    Encrypting/Decrypting(Using AES) Large files and transferring over HTTP

  17. 17

    C# transferring lots of small files over a network

  18. 18

    Script for transferring files over the internet via a Cron task

  19. 19

    Is there a speed difference between transferring files over FTP and Samba?

  20. 20

    Does transferring files over a local network use up internet bandwidth

  21. 21

    How to Find the Bottleneck when Transferring Files over WAN

  22. 22

    Transferring files from remote Mac SSH to school Linux Server

  23. 23

    In Python, how do I get user's remote IP (their last hop) if they're connected over SSH?

  24. 24

    Transferring Files between two EC2 Instances in the same region

  25. 25

    Transferring files between two remote servers that use different protocols

  26. 26

    sh startup files over ssh

  27. 27

    Remove a list of files over SSH

  28. 28

    SFTP over double server hop

  29. 29

    How to multi-hop ssh using connect to server under other locations in Files

HotTag

Archive