Rsync Change SSH Port Number While Making Backups

How do I change my rsync command port number while making backup to remote server at backup1.example.com port 10253 (my ssh server runs on tcp port # 10253)? How do I change port number while using rsync command?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Time1m
Yes, it possible to change or use a different ssh port when using rsync command on Linux or Unix-like operating systems. If your ssh server is running on TCP port # 5000, try the following command to change port number. It is pretty simple command:

ADVERTISEMENTS

rsync -av -e 'ssh -p PORT-NUMBER-HERE' /path/to/source user@backup1.example.com

Use a different ssh port when using rsync

In this example, I am going to backup /home/vivek/ directory to the server called server1.nixcraft.net.in at TCP port number 5000, enter:

rsync -av -e 'ssh -p 5000' /home/vivek backupop@server1.nixcraft.net.in
See also:
  • Man pages: ssh(1)
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
5 comments… add one
  • Vamsi Aug 10, 2010 @ 13:50

    I faced this problem some time ago..but I sorted it out myself after reading the man pages ..lol.
    wish this post was made sometime ago :D

  • DonC Nov 2, 2010 @ 20:03

    We dont use a remote shell, but I need to specify what port the client starts the request on – as well as what port the remote host is listening on. Is that possible?

    For security reasons, we want to allow rsync, but the “random port” from the client is causing me issues.

  • DonC Nov 2, 2010 @ 20:03

    clarification – we dont use a remote shell with rsync. here is the basic command we use in our scripts:

    rsync –verbose user1@5.2.2.5::user1

  • hemant Apr 10, 2013 @ 11:48

    thanks man!!!!

  • Justin Dorfman Jul 27, 2013 @ 20:14

    Thanks Vivek! Please get on Gittip.com so we can pay you!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.