LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-28-2006, 08:06 PM   #1
hueofwind
Member
 
Registered: Nov 2005
Location: Australia
Posts: 49

Rep: Reputation: 15
how to use rsync as root


Hi, everyone:

I met a problem when i tried to use rsync to back up files between two machines. The problem is only when u rsync as root on the target machine can u keep all the file attributes like owner, group. If u use a non-root user, the files' owner and group will be changed to the same as the user being used.

But both two machines, for the security reason, root are disabled for login. In their sshd_config file, PermitRootLogin is set to no.

How can I solve this problem without changing PermitRootLogin? Can sudo be used in this case?

Thanks a lot!

Henry
 
Old 03-29-2006, 10:06 AM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,988

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
If you're not using a script the answer is easy. Login as an ordinary user, su to root, and run rsync. If you are automating the process with a cron script, you want to set up an ssh key for authentication so you don't need to be there to enter a password.
 
Old 03-29-2006, 04:47 PM   #3
hueofwind
Member
 
Registered: Nov 2005
Location: Australia
Posts: 49

Original Poster
Rep: Reputation: 15
thank, kilgoretrout!

But the problem is none of the two machines supports root login, which means if I ssh login to target machine then use rsync, I may not have access right to some directories on source machine.

What's ur opinion?

Henry
 
Old 03-29-2006, 05:16 PM   #4
gr00ve
Member
 
Registered: Jan 2004
Location: varies
Distribution: Blag, Slackware
Posts: 36

Rep: Reputation: 15
Quote:
Originally Posted by hueofwind
But both two machines, for the security reason, root are disabled for login. In their sshd_config file
no root through ssh ok


Quote:
Originally Posted by hueofwind
But the problem is none of the two machines supports root login, which means if I ssh login to target machine then use rsync, I may not have access right to some directories on source machine.
smth like >
rsync -a -e ssh source/ root@remotemachine.com:/path/to/destination/
will not work because before the user is recognized by rsync it is prohibited by sshd right?

so instead what about doing it in this way (just an idea):

sshd at source allows port to be forwarded to whichever is the backup destination + ssh client at the destination is configured to accept the forwarded port
rsync runs locally on source and creates a backup
then through nc & the forwarded port backup file is being transfered to the target machine

do you think this would work in a cron script?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync with permissions, but not as root nifflerX Linux - General 5 09-28-2011 11:14 PM
root permission & rsync ziggie216 Linux - Software 1 12-12-2005 01:21 PM
running rsync as root msound Linux - Security 4 11-09-2005 10:16 AM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM
Anyway to use rsync ssh without allowing root access? ifm Linux - Security 0 06-12-2002 01:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration