The command for this week is SSH. There are a lot of neat things you can do with SSH. Here’s a nice one liner if you get in a pickle.

Background: You are working on remote server HOST_B when you realize that the file your trying to figure out how to configure properly is already working on remote server HOST_A. Unfortunately, you do not have direct access between HOST_A and HOST_B. Now you can easily SSH into HOST_A, SCP the file frpm HOST_A down to your local computer. SCP the file from your local computer to HOST_B and then SSH into HOST_B to put the file in the correct place. Well that takes a bit if time. You can pass information through SSH in order to transfer a file with a pipe.

Below is a one liner that not only transfers the file in this manner, but compresses in one format on HOST_A for faster downlaod, changes the compression type on the local computer so it can be decompressed on HOST_B.

ssh USER@HOST_A ‘cat FILENAME | bzip2′ | bunzip2 | gzip | ssh USER@HOST_B ‘gunzip | cat > FILENAME’

Try it out and let me know what you think.

One Response to “Move a File with SSH by Proxy”
  1. Andy says:

    This was exactly what I wanted :) To test it I created a binary file, transferred it then did an md5sum on it. 100% perfect!

  2.  
Leave a Reply