Linux – rsync: ssh unknown option -p2122

command-line-interfacelinuxportrsyncssh

I run this command to replicate data from one server to another. It's been working for a quite a while. I have this setup as a cron job. Yesterday for some reason, it stopped working. I ran it manually and got this error:

ssh -qt -p2123 user36@219.29.195.71 rsync -az --delete 
--rsh='ssh -p2122 -qt' 
/home/user36/public_html/ user36@142.112.62.206:/home/user36/public_html/

rsync: -p2122: unknown option
rsync error: syntax or usage error (code 1) at main.c(1231) [client=2.6.8]

Note that the full command is executed in a single line, but is shown here in multiple lines for better readability

Why did it suddenly stop working? And why is it throwing the error at the ssh port option?

EDIT: This is on CentOS

Best Answer

You'll need to add quotes around the command you pass via ssh:

ssh -qt -p2123 user36@219.29.195.71 "rsync -az --delete 
--rsh='ssh -p2122 -qt' 
/home/user36/public_html/ user36@142.112.62.206:/home/user36/public_html/"

This will keep the single-quotes from getting stripped out before rsync runs on the remote host.