LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Sudoers and rsync over ssh help (https://www.linuxquestions.org/questions/linux-security-4/sudoers-and-rsync-over-ssh-help-773340/)

MJBoa 12-03-2009 08:56 PM

Sudoers and rsync over ssh help
 
Hi guys. So here's my situation. I have a server I'm about to wipe and rebuild. I have a backup at a remote location but I want the files locally so I can fool around with them and pick and choose what i want on the server. So I want to rsync certain directories over ssh.
Here's what I'm doing.
My rsync command:
rsync -avz -e "ssh -p 22" mjboa@site:/etc/ /home/mike/Documents/Projects/site_backup_12_3_09/etc/ --rsync-path="sudo rsync"

This worked on a different directory so I know I have the basics down.
The confusing part is that I need root access on the remote machine to read /etc but I don't want to PermitRootLogin on sshd.
So I read somewhere that I can set it so that I don't need to enter a password for sudo with just rsync and I can set the command rsync runs on the remote machine. Makes perfect sense.

So I have my sudoers on the remote machine:
mjboa ALL=PASSWD: ALL, NOPASSWD:/usr/bin/rsync

I see nothing wrong with this, even through the screwed syntax of sudoers, and I've had trouble with sudoers before.

What I get out of this is when i log in as mjboa on my server, I don't get prompted for a password at all, for any command.
And when I run the rsync command, it actually prompts me for a password! And it displays it in plain text and does nothing when I enter it.
What the hell is going on? Someone has to have done this successfully before.

Thanks.

Cocoabean 12-04-2009 05:26 PM

Save yourself the headache and just rsync the other way.



ssh mjboa@site
sudo rsync -avz /etc/ localusername@localworkstation:/home/mike/Documents/Projects/site_backup_12_3_09/etc/

kettlewell 10-05-2010 07:46 PM

Quote:

Originally Posted by MJBoa (Post 3779114)
Hi guys. So here's my situation. I have a server I'm about to wipe and rebuild. I have a backup at a remote location but I want the files locally so I can fool around with them and pick and choose what i want on the server. So I want to rsync certain directories over ssh.
Here's what I'm doing.
My rsync command:
rsync -avz -e "ssh -p 22" mjboa@site:/etc/ /home/mike/Documents/Projects/site_backup_12_3_09/etc/ --rsync-path="sudo rsync"

This worked on a different directory so I know I have the basics down.
The confusing part is that I need root access on the remote machine to read /etc but I don't want to PermitRootLogin on sshd.
So I read somewhere that I can set it so that I don't need to enter a password for sudo with just rsync and I can set the command rsync runs on the remote machine. Makes perfect sense.

So I have my sudoers on the remote machine:
mjboa ALL=PASSWD: ALL, NOPASSWD:/usr/bin/rsync

I see nothing wrong with this, even through the screwed syntax of sudoers, and I've had trouble with sudoers before.

What I get out of this is when i log in as mjboa on my server, I don't get prompted for a password at all, for any command.
And when I run the rsync command, it actually prompts me for a password! And it displays it in plain text and does nothing when I enter it.
What the hell is going on? Someone has to have done this successfully before.

Thanks.

Has anyone solved this? I have a dynamic IP for my workstation, and it won't be an option to rsync from server to workstation...

I know that I can set --rsync-path='sudo rsync' ... but I have to disable requiretty, and that's pretty insecure if I understand correctly...


All times are GMT -5. The time now is 11:20 PM.