[Linux](EN) Change port in rsync

Use different port not 22 in rsync

Environment and Prerequisite

  • Linux
  • Bash shell(/bin/bash)
  • rsync



  • Use -e option
  • All of the examples below are written to use port 2222
-e 'ssh -p 2222'

In case when use IP address or domain

  • Format
rsync -e 'ssh -p 2222' [target file or directory] [user]@[IP address or domain]:[destination]
  • Example
rsync -e 'ssh -p 2222' test.txt twpower@

In case when use ~/.ssh/config file

  • Format
Host test_host
    Port 2222
rsync [target file or directory] [host name]:[destination]
  • Example
rsync test.txt test_host:~/test.txt