LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-28-2011, 04:41 AM   #1
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
rsync servers - ssh keys


Hello

After lots of hardware and network failures I get to the conclusion that I need to find out some good solution to backup my mail and web services.
My first try was copying things and archive them to a backup server which is on a separate network (ISP failure cases). Finally that scenario didn't work that well.

After this I found some information about rsync and it seems to me that it can be a good solution.
I need to backup emails > two directories /var/spool/mail and /imap. (for example)

It works with rsync very well: rsync -a --size-only /imap/* rmhost:/imap. But when I try to make it automatically by script I get into a little "situation".
I use the public/private key by ssh for no-password connection. There is a warning about the use of it. The very simplest way is to run the rsync as root for me.
rsync -a --size-only /home/* rmhost:/home
It updates the home of every user on the backup. As in warning with ssh keys it is not a good idea to use keys for root. So I need to run it as some other user (syncer for example) but this user won't be able to access all user directories on the MASTER server. It also won't be able access them on backup.

Is there any "nice" way to manage this problem?
I was thinking about that I can save the ownership of files, change it to syncer before I rsync it with the remote directory and then recover the user ownership of files.
Is this a good idea?

Last edited by hua; 03-01-2011 at 09:41 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-28-2011, 09:28 PM   #2
slimm609
Member
 
Registered: May 2007
Location: Chas, SC
Distribution: slackware, gentoo, fedora, LFS, sidewinder G2, solaris, FreeBSD, RHEL, SUSE, Backtrack
Posts: 430

Rep: Reputation: 67
you have a few options...

PermitRoot in sshd_config allows yes, no, and without-password. without-password only allows keys to be used. this is not a huge security problem in most cases but it certainly depends on the network design that it is being deployed in.


the other option for rsync as root to preserve permissions and backup everything.

this requires ntp to be set up to work correctly as time is a major concern for this to work properly.

to help explain it i will call one server mail and one server backup.

on both servers set up a backup user and configure keys for the backup user.

on the mail server write a cron that checks for a certain file in a backup user writable location. e.g. /tmp/.backupstart
this script checks for the .backupstart file and changes sshd to permitroot without-password and restarts sshd then sleeps for 3-5 minutes then changes the config back to permitroot no and restarts sshd again

on the backup server there are 2 scripts.

one script will ssh to the mail server and touch the .backupstart script and then exit

the other will be the script run as root that starts the backup over ssh with root keys in that 3-5 minute period. this is why the NTP is so important in this case. timing must be perfect.


In a real-world environment the backup server would be placed on a out-of-band network only that is not accessible to the world.

Last edited by slimm609; 04-30-2011 at 09:30 PM.
 
2 members found this post helpful.
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rsync fails in cron - ssh key prob for rsync? jonathansfl Linux - Server 6 12-09-2010 09:48 AM
URGENT - Fix SSH Keys on server1 & server2(AIX Servers) to trust trust3(HP Server) chakri.unix Other *NIX 2 12-02-2008 11:20 AM
SSH host keys VS SSH keys kenneho Linux - Security 3 09-11-2008 06:03 AM
Configuring SSH to accept only keys (already have keys) fr0st Linux - Security 3 11-04-2003 03:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:02 PM.

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