Ssh – Rsync with ssh and root not working after change hosts IP

rsyncssh

We have a server that backup multiples servers. The backups server is located in the office and all other server in the cloud.

We have moved all the server to a new IP, and from this moment the backups stopped. .
In the hosts we have authorized the new IP in the rsync.conf (hosts allow = new IP ) and also in ~/.ssh/nano authorized_keys changing the from like: from="new Ip", ssh-rsa……. root@backup).

But it has not worked, so we generated new key pair without passphrase.

ssh-keygen

And we have copied to the host:

ssh-copy-id -i /root/.ssh/id_dsa.pub user@remote.host.com

We use the combined rsync with ssh and root, thus

rsync -az "ssh -i /root/.ssh/id_dsa.pub" root@remote.host. folder1
folder2

but in this case we have this error:

ERROR: The remote path must start with a module name rsync error:
error starting client-server protocol (code 5) at main.c(1534)
[Receiver=3.0.9] remotehost :~/.ssh# rsync error: received SIGUSR1
(code 19) at main.c(1316) [Receiver=3.0.9]

And in the host server we have this log:

Oct 20 13:35:44 remotehost sshd[21863]: pam_unix(sshd:auth):
authentication failure; logname= uid=0 euid=0 tty=ssh ruser=
rhost=new_IP user=root Oct 20 13:35:46 remotehost sshd[21863]: Failed
password for root from New_IP port 56355 ssh2

In the host the rsync service is runing.

We have tried several methods and followed several manuals.

Can someone help me?,

Thanks in advance!!

Update1:

This is my rsyncd.conf in both node;
In the backup server:

hosts allow = allow IP'S
hosts deny = *
[Remote_Server1]
path= /var/backups/server1
comment = Server1
uid = root
gid = root

[Remote_Server2]
path= /var/backups/server2
comment = Server2
uid = root
gid = root

In the remote Server:

hosts allow = backup server public IP
hosts deny = *
max connections = 48
syslog facility = daemon

[root-server1]
path = /
comment = root directory of my server1
uid = root
gid = root

[etc-server1]
path = /etc
comment = Directory of my server1
uid = root
gid = root

[home-server1]
path = /home
comment = home of my server
uid = root
gid = root

Update2:

I have ssh configured this way:

in /etc/ssh/sshd_config file

PermitRootLogin forced-commands-only
DSAAuthentication yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys

And moreover, in the /root/.ssh/authorized_keys file on the remote server i have (I've done it with this manual http://troy.jdmz.net/rsync/index.html) :

from="My IP",command="/home/remoteuser/cron/validate-rsync"/ ssh-dss ADCD...1234......kEY  root@backupserver

where the validate-rsync file is:

#!/bin/sh

case "$SSH_ORIGINAL_COMMAND" in
*\&*)
echo "Rejected"
;;
*\(*)
echo "Rejected"
;;
*\{*)
echo "Rejected"
;;
*\;*)
echo "Rejected"
;;
*\<*)
echo "Rejected"
;;
*\`*)
echo "Rejected"
;;
*\|*)
echo "Rejected"
;;
rsync\ --server*)
$SSH_ORIGINAL_COMMAND
;;
*)
echo "Rejected"
;;
esac

With this configuration, I run the command:

rsync -azvvv  -e "ssh -i /root/.ssh/rsync.key" root@remoteserver1::home-server1/ /home/local/

In the case i get this error:

pening connection using: ssh -i /root/.ssh/rsync.key -l root
remoteserver1 rsync –server –daemon . rsync: server sent
"**************************************************************************" rather than greeting rsync error: error starting client-server
protocol (code 5) at main.c(1534) [Receiver=3.0.9] [Receiver]
_exit_cleanup(code=5, file=main.c, line=1534): about to call exit(5)

And in the logs i have this:

sshd[10408]: Root login accepted for forced command. sshd[10408]:
Accepted publickey for root from XXX.XXX.XXX port 60543 ssh2
sshd[10408]: pam_unix(sshd:session): session opened for user root by
(uid=0) sshd[10408]: pam_unix(sshd:session): session closed for user
root

Update3:

The problem started since we've moved the servers to other Cloud. In fact, all existing configurations explained in this post works in the old cloud. It can be some upper level application blocking the rsync in the new cloud?. How could I check it? we have already check the ports. Thanks for all.

Best Answer

usual way to do is

ssh-copy-id root@remote.host.com
  • at this point, you usualy enter password for root@distant.

Next step;

rsync  root@remote.host.com folder1 folder2    
  • this will sync with root@remote.host.com home dir, use rsync root@remote.host.com:/data folder1 folder2 to sync with /data

I have trouble

And we have copied to the host:

ssh-copy-id -i /root/.ssh/id_dsa.pub user@remote.host.com

We use the combined rsync with ssh and root, thus

 rsync -az "ssh -i /root/.ssh/id_rsa.pub" root@remote.host.com folder1 folder2
  • you use both dsa and rsa ? or is this a typo ?
  • If id_rsa is your default key, there is no need to specify it.
  • as told, -i flag from ssh require a private key, not .pub available to everybody.
Related Topic