rsync from command line, ssh-key problem?

  • Hello all, can anyone help an rsync newbie?


    I have two OMV machines (call them BoxA and BoxB), both on my home network.


    I need to rsync one folder from BoxA to BoxB using the command line, because I want to rsync only items from the last X days:

    Code
    find . -mtime -X -print0 | rsync -0v --files-from=- BoxA/sourcefolder/ userme@BoxB/backupfolder/

    I've generated a new ssh key pair (without a password) on BoxA with ssh-keygen, then put the contents of the public key file in userme/.ssh/authoried_keys on BoxB


    Then on BoxA, from ssh as [username] I tried:

    Code
    rsync -aP --dry-run sourcefolder/ userme@BoxB:/backupfolder/

    But I got this error:


    Code
    Permission denied (publickey).
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]


    Any pointers welcome!

    OMV 6 on Raspberry Pi 3/4/5, Odroid C2/HC2 and three cobbled together x64 boxes running Snapraid.

  • Thanks for the reply!

    Zitat

    The userme is trying to write to rootfs folder /backupfolder

    Sorry, that was an oversimplification on my part. The target part is more like userme@targetip:/srv/123456789etc/backupfolder - and permissions are OK for userme


    SSH works fine, I'm using putty regularly with pka on all my OMV boxes.


    What I'm trying to do is allow unattended rsyncs by using a new key without a password, e.g. using this guide.


    I created a new keypair on BoxA and added the new pubkey to userme on BoxB via the GUI, but I get the same result as above.


    Should I create a new 'rsync' user with their own key so the target part is userrsync@targetip:/srv/123456789etc/backupfolder
    and then adjust permissions accordingly?


    Thanks again.

    OMV 6 on Raspberry Pi 3/4/5, Odroid C2/HC2 and three cobbled together x64 boxes running Snapraid.

  • Aha, that seems to do the trick:


    Code
    rsync -aP --dry-run  -e "ssh -i new-rsync-key" /srv/dev-disk-by-label-bigdisk/sourcefolder/ userme@BoxB:/srv/123456789etc/backupfolder/

    So for the record, the only other thing I did was run this on BoxA:
    ssh-keygen -e -f new-rsync-key



    ...to export my public key in the right format. I copied the output of that to the keys tab of UserMe in the users section on BoxB in the webui, where it sits alongside UserMe's proper password-protected SSH key.


    So far so good! Thanks subzero79!

    OMV 6 on Raspberry Pi 3/4/5, Odroid C2/HC2 and three cobbled together x64 boxes running Snapraid.

    Einmal editiert, zuletzt von NothingNowhere ()

  • Had some tweaking to get this running as intended this seems to do it:



    Code
    find /srv/sourcefolder/ -mtime -14 -printf %P\\0  | rsync -vP --files-from=- --checksum -e "ssh -i userme-rsync-key" --from0 /srv/sourcefolder/ userme@BoxB:/srv/targetfolder

    This rsyncs anything from the last 14 days, based on checksum differences.

    OMV 6 on Raspberry Pi 3/4/5, Odroid C2/HC2 and three cobbled together x64 boxes running Snapraid.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!