Running lsyncd on Ubuntu 16.04

Akitogo Team, 08 Mar 2018

This is a quick technical note for running lsyncd on Ubuntu 16.04. Assuming that you have installed lsyncd successfully as a service and you want to sync files which have root read only permission to another Ubuntu server. If you don't have proper access to the destination server you might find in your lsyncd.log something like 

rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
Thu Mar  8 10:54:47 2018 Error: Temporary or permanent failure on startup of "/etc/blabla/". Terminating since "insist" is not set.
Thu Mar  8 10:58:21 2018 Normal: recursive startup rsync: /etc/blabla/ -> x.x.x.:/etc/blabla/
Host key verification failed.

Here are the steps you have to take:

  • On source server, change to root using 
    sudo -i
    

    Generate ssh keys using 

    ssh-keygen -t rsa
    
  • On destination server, make sure that root login is enabled, instructions can be found here: How to enable ssh root access ubuntu 16.04
  • On source server, now copy ssh key to destination server using
    ssh-copy-id -i ~/.ssh/id_rsa.pub root@DestinationServer
    
  • On destination server you might want to disable again password login for root. 
    sudo vi /etc/ssh/sshd_config
    
    Change:
    PasswordAuthentication no
    PermitRootLogin without-password
    
    Save changes and
    sudo service ssh restart