RSync with a non-standard SSH Port

Posted on December 8, 2007

While doing some work on the JQuery Plugins site today, I needed to use rsync over ssh. The ssh daemon on the remote server runs on a non-standard port, and all the port related options to rsync only change settings if you’re running the rsync-daemon.

After some searching, the man page of rsync finally offered a solution:

rsync -avz -e "ssh -p $portNumber" [email protected]:/path/to/files/ /local/path/

Passing the port parameter to ssh with the -e option worked like a charm. 🙂

This is why Unix rocks.


70 Replies to "RSync with a non-standard SSH Port"

  • ikke
    May 10, 2008 (10:59 am)
    Reply

    Thanks for this….. Had the same problem, now the same solution 🙂

  • Daniel
    November 12, 2008 (7:35 pm)
    Reply

    Wonderful… just what I was looking for…

  • Anonymous
    December 19, 2008 (2:18 pm)
    Reply

    Thank you. This is why google rocks… “rsync ssh non standard port”. You helped a lot. Thanks for posting.

  • Colin-uk.com » Blog Archive » Rsync tips
    February 22, 2010 (11:19 pm)
    Reply

    […] http://amountaintop.com/rsync-non-standard-ssh-port […]

  • ling
    April 26, 2010 (8:24 am)
    Reply

    Thanks a lot for this, just what I needed 😉

  • Leonardo Gregory Brunnet
    April 10, 2011 (6:34 pm)
    Reply

    Thank you for the tip. It is always hard to grep solutions on man pages.

  • Tendydon
    May 3, 2011 (7:55 am)
    Reply

    Thanks a lot I was also wondering how

  • Leon Nardella
    May 14, 2011 (6:39 am)
    Reply

    Thank you very much!
    I had been losing my hair after this one!

  • Cristobal
    May 19, 2011 (3:26 pm)
    Reply

     Gracias.

  • Guillermo
    August 1, 2011 (12:25 pm)
    Reply

    That was indeed useful.

  • Jpenguin
    August 3, 2011 (9:13 pm)
    Reply

    Cool useful!

  • Durand
    August 7, 2011 (8:37 am)
    Reply

    Thanks a lot!

  • Marklar
    September 2, 2011 (7:21 pm)
    Reply

    Anyone know how to get this to work on Windows?

    I installed cwRSync on Windows.  I tried the command, but when /local/path is C:something it gives an error about both directories being remote.  Any ideas?

    • synack
      September 29, 2011 (11:48 am)
      Reply

      Here is the comman fro the script that I use to backup my windows workstation to and offite linux box –  rsync -avzO -e “ssh -p 6883” –delete /cygdrive/c/data c %bkupuser%@bs01.g33k2.com:~/backups/daily01

      You have to used the /cygdrive/ when refering to local drives with cygwin tools.

  • Ondrej Jombík
    October 10, 2011 (9:54 pm)
    Reply

    Thanks man, this was exactly I was looking for! 🙂

  • Pete
    January 10, 2012 (3:33 am)
    Reply

    Ditto!!!

  • Joe
    March 6, 2012 (7:22 pm)
    Reply

    Thanks!

  • Guug
    March 23, 2012 (12:49 am)
    Reply

    Well done! 🙂

  • Geno
    March 27, 2012 (1:39 pm)
    Reply

    thanks a ton!

  • Expresso Viva
    April 11, 2012 (4:39 am)
    Reply

    god job
    thx lots

  • jon
    July 4, 2012 (10:22 pm)
    Reply

    thank you…you saved me a whole lot of time

  • Adam
    July 23, 2012 (12:36 am)
    Reply

    Just to verify, will this login to an ssh shell before staring any rsync traffic?  I want to make sure the rsync is encrypted both directions before doing this to a remote server, i.e. it’s encrypted when I switch SRC/DEST:
    rsync -avz -e “ssh -p $portNumber” /local/path/ [email protected]:/path/to/files/

  • dave
    October 17, 2012 (9:12 am)
    Reply

    The post that keeps on giving. Thanks!

  • John Goodwin
    November 16, 2012 (10:54 am)
    Reply

     And another vote of thanks! Trying to backup all my data from my PC to my new HP N40L microserver and I fell at the first hurdle. A quick Google search and I found this. I pass on my thanks, cheers.

    John G

  • Alexey Moseyev
    January 9, 2013 (3:52 pm)
    Reply

    Thank you!

  • escapefromthebluebedroom
    March 20, 2013 (12:34 pm)
    Reply

    Excellent, exactly what I was looking for!

  • Lee Burchett
    April 24, 2013 (9:26 am)
    Reply

    Thanks. This is just what I was looking for.

  • NO
    May 2, 2013 (3:29 pm)
    Reply

    Thanks / Saved my “night” …

  • AsherBond
    May 13, 2013 (2:09 am)
    Reply

    I had a feeling I should have specified the port first. Helpful. – Asher Bond

  • thirdnormal
    May 17, 2013 (12:08 pm)
    Reply

    Thank you. This worked perfectly for me.

  • Raul Montagne
    May 22, 2013 (7:41 am)
    Reply

    Thank you! just what I was looking for!

  • Cristóbal Vio
    June 25, 2013 (11:44 pm)
    Reply

    thx!!

  • Rsync with a non-standard ssh port – Mike Hostetler | Pork Belly
    July 20, 2013 (4:19 am)
    Reply

    […] Rsync with a non-standard ssh port – Mike Hostetler. […]

  • VINOJ
    August 13, 2014 (2:38 am)
    Reply

    Thanks mate…

  • Symphozik
    August 21, 2014 (2:53 pm)
    Reply

    Perfect, just what I needed! Thanks.

  • Veerasamy Kaunder
    September 1, 2014 (2:11 am)
    Reply

    Thanks, i was needing this, and your suggestions worked.. Thanks again.

  • MrCambron
    November 4, 2014 (2:57 pm)
    Reply

    I got some weird error message:
    ——-
    protocol version mismatch — is your shell clean?

    (see the rsync man page for an explanation)

    rsync error: protocol incompatibility (code 2) at /SourceCache/rsync/rsync-42/rsync/compat.c(61) [receiver=2.6.9]

    ——-

    My server is a Windows 7 machine and using some gui ssh server that I downloaded from a quick google search. And running the rsync command from my Mac OSX 10.9 machine.

  • David
    February 10, 2015 (7:40 am)
    Reply

    Thanks!

  • zaiger
    March 4, 2015 (5:29 pm)
    Reply

    Perfect, I was missing the -e parameter. Thank you!

  • mjp1800
    March 24, 2015 (4:07 pm)
    Reply

    This worked great for backing up a remote NAS to a local destination. How would the command be restructured for sending files in the other direction?

  • 如何rsync同步非标准SSH接口 | argcv
    March 26, 2015 (4:59 am)
    Reply

    […] reference : Rsync with a non-standard ssh port […]

  • Nadav Kavalerchik
    May 30, 2015 (3:53 am)
    Reply

    Thanks!

  • Theo Kouzelis
    August 28, 2015 (12:04 pm)
    Reply

    Awesome thanks

  • Bruno Sousa
    August 28, 2015 (1:21 pm)
    Reply

    Thanks for this….. Had the same problem, now the same solution 🙂

  • Jeremy Glover
    September 17, 2015 (8:43 am)
    Reply

    Yay! Worked for me. Thanks!

  • tophibiz
    September 24, 2015 (10:56 am)
    Reply

    Works like e charm 10x

  • Adler Santos
    October 7, 2015 (11:32 pm)
    Reply

    Thank you! This is the simplest solution. I’m surprised this isn’t mentioned enough anywhere else.

  • Wildan Fathan
    October 15, 2015 (8:22 pm)
    Reply

    It’s work. thankyou bro

  • Robert Smith
    December 16, 2015 (10:46 am)
    Reply

    Thanks a lot!!

  • Zemtvs
    January 27, 2016 (9:25 pm)
    Reply

    Thanks. I used $ sign with port number, then i realized that $ sign should not be used. worked

  • Katy
    August 7, 2016 (2:54 am)
    Reply

    Thanks!

  • Rsync avec un port non standard - Hackeur.xyz
    August 23, 2016 (5:07 pm)
    Reply

    […] Source : Le blog de Mike Hostetler […]

  • Rsync přes nestandardní port | Jr's page
    September 2, 2016 (3:53 am)
    Reply

    […] Zdroj: http://mike-hostetler.com/blog/2007/12/08/rsync-non-standard-ssh-port/ […]

  • Ramires Teixeira
    October 24, 2016 (9:14 pm)
    Reply

    Thank you so much for this!

  • Thomas Varghese
    December 15, 2016 (12:59 am)
    Reply

    Worked like a Charm!! 🙂

  • Grego
    January 10, 2017 (1:39 pm)
    Reply

    Yep, worked for me. I saw –port=[otherport] on the manpage, but that didn’t work. Your parameter did the trick. Thanks

  • Al
    January 31, 2017 (4:50 am)
    Reply

    MASSIVE HELP! Thanks.

  • Stefan Petrounov
    March 15, 2017 (4:03 pm)
    Reply

    Thanks for reminding us to read the manuals 🙂 And for the shortcut to the solution of course! Regards,
    Stefan

  • P.K. Hunter
    March 24, 2017 (5:01 am)
    Reply

    How about multifactor authentication. If SSH requires that verification code, how do we ensure rsync can also use that?

  • Hell Mouth
    May 18, 2017 (6:36 pm)
    Reply

    Thumbs up!

  • Wendal Chen
    July 24, 2017 (9:07 pm)
    Reply

    good!

  • Luis Fontana
    September 3, 2017 (9:10 am)
    Reply

    Merci 🙂

  • Maja Kessler
    October 2, 2017 (6:37 am)
    Reply

    Big thanks! Still working fine in 2017 🙂

  • jack reacher
    December 2, 2017 (2:51 pm)
    Reply

    nice article

  • Baretto James
    December 12, 2017 (8:45 am)
    Reply

    While searching for the same thing “rsync non standard port” I came across a blog recommending me to use GS Richcopy 360. It had a trial period, so I used it and yes it solved the errors and I completely replaced Rsync with this. GS richcopy is even better than rsync. Nice post by the way!

  • AmericanPenguin
    February 2, 2018 (9:45 am)
    Reply

    Works. Thanks.

  • Patrizio Bekerle
    July 17, 2018 (12:48 am)
    Reply

    Thanks for the help!

  • ros ros
    July 17, 2018 (1:01 pm)
    Reply

    Isn’t that just awesome?

  • cocotucafe
    September 30, 2018 (9:51 pm)
    Reply

    Good work! I like using rsync to backup local files to a remote server. Thanks!


Leave a Reply