View Single Post
Old 4th March 2013, 22:14
fantalimon fantalimon is offline
Junior Member
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how use rsync as sudo to copy access_logs from remote server

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.
Reply With Quote
Sponsored Links