I'd like to download a file from server C, through server B (bastion) to my local server A.

Normally I'd handle the mess in ssh/config with ProxyCommand, but in this case I can't. Can we make a one-liner with rsync which still would allow me to do the above?


This is quite the one-liner, but you can do the following:

 rsync -e 'ssh -o ProxyCommand="ssh -W %h:%p user@B"' user@C:file .
  • 2
    In newer versions of ssh, you can also use the -J ssh command-line argument to make a shorter and more readable command: rsync -e 'ssh -J user@B' user@C:file . Nov 19 '19 at 6:24
  • @theferrit32 that's a proper answer on its own. If you make it an answer I'll accept it in favor of my own
    – hbogert
    Mar 16 at 13:50
  • o.c. I meant to say, "I'll unaccept my answer, in favor of your answer"
    – hbogert
    Aug 12 at 7:12

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.