How to Use rsync on a Different SSH Port

If the computer you’re connecting to is running SSH on a different port than the standard (22), you’ll have to specify an extra option in your rsync command. This guide shows the correct syntax to use the rsync command on a different port than 22.

The normal rsync-over-ssh command uses port 22 by default and looks something like this:

$ rsync -ave ssh /my/files/ user@hostname:/path/to/files/

To use a non-default port with rsync and SSH, we’ll add the -p option. In this example, we assume SSH is running on port 2222.

$ rsync -ave 'ssh -p 2222' /my/files/ user@hostname:/path/to/files/

That’s all there is to it. Substitute whatever number necessary in place of 2222 in our example.

Leave a Comment

Your email address will not be published. Required fields are marked *