Search code examples
sshrsync

SSH into server and rsync from there – with non-standard port


I have two servers with non-standard ssh ports:

  • liveserver.com -p 123
  • testserver.com -p 456

To sync data from liveserver to testserver, I thought I'd ssh into testserver and rsync the data to local (aka testserver) from there.

ssh [email protected] -p 456 rsync -zra -e "ssh -p 123 --delete --exclude='.env' [email protected]:/path/to/dump.bz2 path/to;

This gives me

Unexpected remote arg: [email protected]:/path/to/dump.bz2
rsync error: syntax or usage error (code 1) at main.c(1354) [sender=3.1.3]

Is my concept wrong or just the syntax?


Solution

  • ssh [email protected] -p 456 "rsync -zra -e 'ssh -p 123' --delete --exclude=.env [email protected]:/path/to/dump.bz2 path/to"
    

    not tested