# Need help with rsync syntax [SOLVED]

## tabanus

I want to backup an ftp server by rsync via SSH over the internet to a remote server. The local machine has an SSH daemon running on a non-standard port, but I can't work out how to incorporate this into my command.

First of all, 

```
rsync -av /tmp/Test_Dir/ ~/Backup_Dir/
```

works all OK on the local machine. Now to tunnel through SSH on port 22 the command:

```
rsync -av localhost:/temp/Test_Dir/ ~/Backup_Dir/
```

appears to work - it asks me for a password at least.

So a couple of questions:

1. How do I incorporate a port number into the rsync command?

2. How do I stop it asking for a password? Is it possible to use public/private keys somehow?

Thanks

----------

## lxg

```
rsync -e 'ssh -p <port>' [other options/parameters]
```

2. Yes, just the same way you would set up a public key based SSH login. In fact, set that up first, rsync will automatically work when this is set.

By the way, have a look at rsnapshot if you're using rsync for serious backups.

----------

## Hu

I have not tried this, but the manual page states that you can use -e to specify both the remote transport and arguments to it.  It shows using this to tell ssh to use an alternate port.  You could also set an ssh_config entry so that ssh always uses the proper port when accessing that host.

----------

## lxg

I'm using this syntax in a couple of deployment scripts, and they work flawlessly.  :Smile: 

----------

## tabanus

 *lxg wrote:*   

> I'm using this syntax in a couple of deployment scripts, and they work flawlessly. 

 

Thanks, I'll try that tomorrow

[EDIT] Yep, works great, thanks

----------

