[Linux](EN) Change port in rsync
Use different port not 22 in rsync
Environment and Prerequisite
- Linux
- Bash shell(/bin/bash)
- rsync
rsync
Method
- 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@192.168.1.2:~/test.txt
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