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.
ikke
May 10, 2008 (10:59 am)
Thanks for this….. Had the same problem, now the same solution 🙂
Daniel
November 12, 2008 (7:35 pm)
Wonderful… just what I was looking for…
Anonymous
December 19, 2008 (2:18 pm)
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)
[…] http://amountaintop.com/rsync-non-standard-ssh-port […]
ling
April 26, 2010 (8:24 am)
Thanks a lot for this, just what I needed 😉
Leonardo Gregory Brunnet
April 10, 2011 (6:34 pm)
Thank you for the tip. It is always hard to grep solutions on man pages.
Tendydon
May 3, 2011 (7:55 am)
Thanks a lot I was also wondering how
Leon Nardella
May 14, 2011 (6:39 am)
Thank you very much!
I had been losing my hair after this one!
Cristobal
May 19, 2011 (3:26 pm)
Gracias.
Guillermo
August 1, 2011 (12:25 pm)
That was indeed useful.
Jpenguin
August 3, 2011 (9:13 pm)
Cool useful!
Durand
August 7, 2011 (8:37 am)
Thanks a lot!
Marklar
September 2, 2011 (7:21 pm)
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)
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)
Thanks man, this was exactly I was looking for! 🙂
Pete
January 10, 2012 (3:33 am)
Ditto!!!
Joe
March 6, 2012 (7:22 pm)
Thanks!
Guug
March 23, 2012 (12:49 am)
Well done! 🙂
Geno
March 27, 2012 (1:39 pm)
thanks a ton!
Expresso Viva
April 11, 2012 (4:39 am)
god job
thx lots
jon
July 4, 2012 (10:22 pm)
thank you…you saved me a whole lot of time
Adam
July 23, 2012 (12:36 am)
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)
The post that keeps on giving. Thanks!
John Goodwin
November 16, 2012 (10:54 am)
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)
Thank you!
Rsync : Synchronize local with shared hosting « Welcome to Abdul Malik Ikhsan's Blog
January 26, 2013 (4:01 am)
[…] : Image : http://www.haykranen.nl/app/uploads/2008/05/timemachine.jpg Source : 1. http://mike-hostetler.com/blog/2007/12/08/rsync-non-standard-ssh-port/ 2. […]
escapefromthebluebedroom
March 20, 2013 (12:34 pm)
Excellent, exactly what I was looking for!
Lee Burchett
April 24, 2013 (9:26 am)
Thanks. This is just what I was looking for.
NO
May 2, 2013 (3:29 pm)
Thanks / Saved my “night” …
AsherBond
May 13, 2013 (2:09 am)
I had a feeling I should have specified the port first. Helpful. – Asher Bond
thirdnormal
May 17, 2013 (12:08 pm)
Thank you. This worked perfectly for me.
Raul Montagne
May 22, 2013 (7:41 am)
Thank you! just what I was looking for!
Cristóbal Vio
June 25, 2013 (11:44 pm)
thx!!
Rsync with a non-standard ssh port – Mike Hostetler | Pork Belly
July 20, 2013 (4:19 am)
[…] Rsync with a non-standard ssh port – Mike Hostetler. […]
VINOJ
August 13, 2014 (2:38 am)
Thanks mate…
Symphozik
August 21, 2014 (2:53 pm)
Perfect, just what I needed! Thanks.
Veerasamy Kaunder
September 1, 2014 (2:11 am)
Thanks, i was needing this, and your suggestions worked.. Thanks again.
MrCambron
November 4, 2014 (2:57 pm)
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)
Thanks!
zaiger
March 4, 2015 (5:29 pm)
Perfect, I was missing the -e parameter. Thank you!
mjp1800
March 24, 2015 (4:07 pm)
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)
[…] reference : Rsync with a non-standard ssh port […]
Nadav Kavalerchik
May 30, 2015 (3:53 am)
Thanks!
Theo Kouzelis
August 28, 2015 (12:04 pm)
Awesome thanks
Bruno Sousa
August 28, 2015 (1:21 pm)
Thanks for this….. Had the same problem, now the same solution 🙂
Jeremy Glover
September 17, 2015 (8:43 am)
Yay! Worked for me. Thanks!
tophibiz
September 24, 2015 (10:56 am)
Works like e charm 10x
Adler Santos
October 7, 2015 (11:32 pm)
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)
It’s work. thankyou bro
Robert Smith
December 16, 2015 (10:46 am)
Thanks a lot!!
Zemtvs
January 27, 2016 (9:25 pm)
Thanks. I used $ sign with port number, then i realized that $ sign should not be used. worked
Katy
August 7, 2016 (2:54 am)
Thanks!
Rsync avec un port non standard - Hackeur.xyz
August 23, 2016 (5:07 pm)
[…] Source : Le blog de Mike Hostetler […]
Rsync přes nestandardní port | Jr's page
September 2, 2016 (3:53 am)
[…] Zdroj: http://mike-hostetler.com/blog/2007/12/08/rsync-non-standard-ssh-port/ […]
Ramires Teixeira
October 24, 2016 (9:14 pm)
Thank you so much for this!
Thomas Varghese
December 15, 2016 (12:59 am)
Worked like a Charm!! 🙂
Grego
January 10, 2017 (1:39 pm)
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)
MASSIVE HELP! Thanks.
Stefan Petrounov
March 15, 2017 (4:03 pm)
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)
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)
Thumbs up!
Wendal Chen
July 24, 2017 (9:07 pm)
good!
Luis Fontana
September 3, 2017 (9:10 am)
Merci 🙂
Maja Kessler
October 2, 2017 (6:37 am)
Big thanks! Still working fine in 2017 🙂
jack reacher
December 2, 2017 (2:51 pm)
nice article
Baretto James
December 12, 2017 (8:45 am)
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)
Works. Thanks.
Patrizio Bekerle
July 17, 2018 (12:48 am)
Thanks for the help!
ros ros
July 17, 2018 (1:01 pm)
Isn’t that just awesome?
cocotucafe
September 30, 2018 (9:51 pm)
Good work! I like using rsync to backup local files to a remote server. Thanks!
mikefoss18
October 11, 2018 (3:33 pm)
Over 10 years later and this short post is still helpful. Thanks!
Dennis
January 10, 2019 (6:03 am)
Odd, but works – 1st hit from google, for a reason 😉
Paul
March 7, 2019 (11:51 am)
Eleven years after the post, it’s still helping people =D
Blaine Simpson
March 28, 2019 (8:51 am)
I’ve been doing this for many years. I find that in most cases it’s more convenient to set the port in ~/.ssh/config rather than having to give it explicitly in every rsync command. If you want to use the alternate port only with rsync attempts (not for other ssh uses), then just define a host alias in ~/.ssh/config. You can also use this tactic for other extremely useful ssh options like to set StrictHostKeyChecking to no, set IdentityFile, set PreferredAuthentications, etc.
ugh
May 21, 2019 (10:33 pm)
This is why Unix sucks.
Y’all are delusional if you think that having trouble figuring out something like this is a feature and not a bug.
hans
June 11, 2019 (3:36 pm)
Thanks a lot, merci viu mou
anon
January 2, 2020 (10:08 am)
still useful 🙂 thanks!
Aaron
February 11, 2020 (11:28 am)
Thanks. The man page wasn’t helpful.
jojo
February 17, 2020 (4:11 am)
Thanks a lot also from me! needed it urgently. Your post was first hit in google and immediately helped!
Vitor Calisto Silva
March 30, 2020 (8:46 am)
Thank you for this, it helped a lot.
Robert Bain
April 25, 2020 (5:50 am)
Thank you for this great info! 😀
Konstantinos
April 27, 2020 (1:29 pm)
Kudos to the man! 13 years later this post saves us all a fair bit of time and frustration