Best practices state that you should run ssh on an non-standard port. Unfortunately some programs use port 22 by default and it isn’t obvious what the switch is to change this port.

One of these programs is the eminently useful rsync. It states how to do this in the man file, but it is hidden and non-obvious. You simply add the option via the -e command to pass ssh options. -e is the shell rsync uses to connect to a remote host.

Using rsync on an alternate ssh port

rsync -avz -e "ssh -p $port" username@ip:/path/to/files/ /local/files/

Using rsync with an openssh key

rsync -avz -e "ssh -i /path/to/private/key" username@ip:/path/to/files/ /local/files/

Or with both an alternate port and openssh key:

rsync -avz -e "ssh -i /path/to/private/key -p $port" username@ip:/path/to/files/ /local/files/

This can be used in a bash script if you set the $port variable or directly on the command line by using the set port instead of $port.

Here are some other useful pages regarding using rsync. If you don’t use rsync for remote file transfer – I highly recommend it. The transfer speed is much faster than scp over ssh.

4 comments
  1.  
    I found your blog ( ) and interested in paid post. Let me know if you are interested then I will give you more details.

    I can offer you best to make it worth your time.

    Regards

Comments are closed.

You May Also Like

Clearing spamassassin BAYES filter tokens

I recently had a problem where my Spamassassin install started thinking that…

Simple Disk Benchmarking in Linux Using ‘dd’

A great way to do a real-world disk test on your linux…

Firesheep Should Be A Call To Arms For System, Network & Web Admins

Firesheep by Eric Butler has just been released to the world. This Firefox plugin does a few things that have already been fairly easy to do for a while, but rolled up in one easy to use package: Sniffs data on unencrypted Wireless Networks Looks for unencrypted login cookies sent to known popular insecure sites Allows you to login to that account with ‘One Click’ So what sites are impacted by default? Amazon.com, Basecamp, bit.ly, Cisco, CNET, Dropbox, Enom, Evernote, Facebook, Flickr, Github, Google, HackerNews, Harvest, Windows Live, NY Times, Pivotal Tracker, Slicehost, tumblr, Twitter, WordPress, Yahoo, and Yelp are among the few. A plugin system allows anyone to add their own sites (and cookie styles) to the plugin. Yikes! It goes without saying that this is a major security problem for anyone who uses unencrypted wireless networks. Includes on this list are many universities and companies such as Starbucks.