Remote copy directories and files through an SSH tunnel host

rsync -avz -e 'ssh -A sshproxy ssh' srcdir remhost:dest/path/
If you have lots of remote hosts sitting "behind" an ssh proxy host, then there is a special-case use of "rsynch" that allows one to easily copy directories and files across the ssh proxy host, without having to do two explicit copies: the '-e' option allows for a replacement "rsh" command. We use this option to specify an "ssh" tunnel command, with the '-A' option that causes authentication agent requests to be forwarded back to the local host. If you have ssh set up correctly, the above command can be done without any passwords being entered.

5
By: totoro
2009-03-25 21:29:07

What Others Think

This is neat. I'm sure many people (including myself) don't know enough about forwarding credentials and other ssh tricks.
bwoodacre · 495 weeks and 6 days ago
ssh rocks!
alperyilmaz · 495 weeks and 6 days ago
Hi. I need to encrypt transfers and I am not sure if rsync does encrypt from sshproxy to my pc.
hectorlara · 413 weeks and 4 days ago
@hectorlara, using the ssh tunnel does, in fact encrypt the rsync contents between the end points. Please read "man rsync" for more details, such as using an encrypted tunnel to an rsync daemon.
totoro · 413 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: