Error copying files between servers [closed]

2

I am copying files via rsync between two linux servers, the command I am using is:

rsync -Cravzpt --remove-source-files --exclude 'script.sh' --exclude 'index.php' /var/www/html/bkpserver/tarefario [email protected]:/var/www/html/

But when I run this command, it asks for the root password and after a few seconds, it displays the following error:

ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender] 
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]

I have no idea why you are having this error, because I have exactly the same command on 3 different servers and copying to the same destination server and they all work.

    
asked by anonymous 19.07.2017 / 23:01

2 answers

0

I was not able to connect to the destination server because the source server did not have an RSA key. I followed the tutorial "Generating the SSH keys and automating the access" that is found in the link: Remote backups with rSync and SSH keys and backup started work normally.

    
22.07.2017 / 03:54
1

The error message says that the server refused the connection, it could be a firewall blocking, a router in the middle of the connection or the port 22 of ssh closed. Try the following (examples here assume debian or ubuntu):

1) See if the ssh service is active

$ sudo /etc/init.d/ssh status
[sudo] senha para sidon: 
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Qui 2017-07-20 08:27:25 BRT; 4h 36min ago
  Process: 1896 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
 Main PID: 1145 (sshd)
    Tasks: 1
   Memory: 1.4M
      CPU: 23ms
   CGroup: /system.slice/ssh.service
           └─1145 /usr/sbin/sshd -D

Notice the line Active: active (running)...

2) If running, check which port:

~$ sudo cat /etc/ssh/sshd_config | grep Port
Port 22

3) See if the door is open:

sudo netstat -pln | grep '22'
tcp        0      0 0.0.0.0:22          0.0.0.0:*           OUÇA   1145/sshd       
tcp6       0      0 :::22               :::*                OUÇA   1145/sshd        

Do this on the server side that is not accepting the connection.

If all of this is OK (SSH active on port 22 open, no firewall blocking) see if the server is connected to a router, in which case the router works like, say, an intermediary or even a "firewall" then you need to do a NAT redirect, ie when the rsync command requests port 22, the request "hits" the router and it does not know what to do, so you have to redirect the 22 to the ip of the server.

    
20.07.2017 / 18:18