Rsync Change SSH Port Number While Making Backups

www.lau‮‬tturi.com
Rsync Change SSH Port Number While Making Backups

To change the SSH port number while making backups with rsync, you can use the -e option to specify the ssh command that rsync should use to connect to the remote host.

For example, if you want to use port 2222 for the SSH connection, you can use the following rsync command:

rsync -avz -e "ssh -p 2222" /local/path user@remote:/remote/path

This will use the ssh command with the -p option to specify the port number (2222) to connect to the remote host.

You can also specify the port number in the ssh_config file on the local machine. This can be useful if you need to use a different port number for multiple backups.

To do this, open the ssh_config file (located in ~/.ssh/ on the local machine) and add the following entry:

Host remote-server
    Port 2222

This will configure the ssh command to use port 2222 when connecting to the remote host remote-server.

You can then use the rsync command without the -e option to connect to the remote host:

rsync -avz /local/path user@remote:/remote/path

Keep in mind that you will need to have permission to access the remote host on the specified port. If you do not have permission, you may need to ask the remote host administrator to open the port or use a different port that you have permission to access.

Created Time:2017-10-30 14:27:16  Author:lautturi