how use rsync as sudo to copy access_logs from remote server

Discussion in 'Server Operation' started by fantalimon, Mar 4, 2013.

  1. fantalimon

    fantalimon New Member

    I'm trying to copy compressed access_log.gz files from /var/log/httpd from a remote server to a local one so that our marketing guy can download them.

    There's probably a better way to do this... but this is what I have tried so far and having problem after problem

    Have created a webuser account on both servers and added
    webuser ALL=(root)NOPASSWD:/usr/bin/rsync at the bottom of /etc/sudoers file

    In /home/webuser I placed this file called sync-log

    ssh -t webuser@ipaddressofremoteserver rsync -varltpgzhP --rsync-path='sudo rsync' \/var/log/httpd/*.gz webuser@ipaddressofremoteserver:/var/www/html/accesslogs/A

    When I run the file as webuser, this is the output:-

    webuser@ipaddressofremoteserver's password:
    sudo: invalid option -- -
    protocol version mismatch -- is your shell clean?
    (see the rsync man page for an explanation)
    rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]

    I have generated and copied the keys from the remote server to the local, ssh-copy-id -i ~/.ssh/ remote-host. In the known_hosts file of the local server i see the key of the remote server listed, yet, when i run the sync file i'm still asked for the password... not sure why..

    any guidance would be greatly appreciated.

Share This Page