It’s fairly common that server admins will change the port that the SSH daemon listens on, to something other than 22. It’s security by obscurity; adding just a little extra hard work for those nefarious people trying to access public-facing machines they don’t own.

Unfortunately this makes it a bit more tricky to use a number of ssh-enabled commands since it’s not always obvious how to pass the alternative port through. With rsync, it’s pretty easy once you know how.

A normal rsync command to sync files from a remote machine to a local machine—over port 22—would look something like this:

rsync -rav nick@myhostname.com:/home/nick/somedirectory .

So, if instead we wanted to use port 12345, we simply add the --rsh= switch (or -e, which is an alias) to our command. This allows us to specify a *r*emote *sh*ell to connect to; in other words, the parameters to pass to the ssh command. Here’s how it looks:

rsync -rav --rsh='ssh -p12345' nick@myhostname.com:/home/nick/somedirectory .

or using the -e alias:

rsync -rav -e 'ssh -p12345' nick@myhostname.com:/home/nick/somedirectory .

Hopefully that saves a few headaches…

Comments for "Linux Tip: Connecting to a Remote Shell with RSync on a Port other than :22"

Commenting is now closed for this article

About

beardscratchers.com is a music-focused web experiment and creative-arts journal from London, England.

Subscribe/Syndicate

Categories

Previous Entries…

Journal content and design are © of Nick Skelton

built with web standards and a baseline.