Batching Copying Files Across Network
I've read a lot of posts on multiple sites about this, but not one post that seems to combine BOTH the ability to BATCH copy files over a network (i.e. scp) with a secure solution.
The goal is to routinely backup files from Linux box A to Linux box B via cron job. So obviously, entering a password isn't an option, and using a password-less login is of course not secure. So how best to get this done? |
Usually rsync is a good way to go for transferring multiple files. The sftp program works, too, but cannot easily resume if interrupted. Both work over SSH so that means you can use keys.
Code:
rsync -a -v -H -e "ssh -i ~/.ssh/somekey.rsa" \ Usually if you do not use a passphrase on your key you should lock it down substantially with a forced command on the server. Otherwise, with a little bit of configuration, you can use an agent to hold the key for that connection. |
Thanks. Since your post, I have been reading up on rsync and rsync_t and my eyes are glazing over. Seems pretty complicated.
|
You can go quite deep, but that is not really necessary. With password authentication, via SSH, you would run it like this:
Code:
rsync -a -v -H \ Can you give more details about the transfer you have in mind and how you have used rsync so far. Also, how have you been using keys for regular SSH connections? |
Thanks! I'll give it a try.
|
Passwordless SSH keys are not insecure. Its the standard way of unattended copying to remote hosts.
Set up your passwordless SSH keys under your preferred user: http://www.linuxproblem.org/art_9.html That will probably save your key as .ssh/id_rsa.pub unless you specify otherwise. Open up your cron as that user: Code:
su - user1 Code:
*/30 * * * * rsync -varh -e "ssh -i ~/.ssh/id_rsa.pub" /local/source/dir/ remoteuser@remotemachine:/remote/dest/dir/ |
Super, sz. I think I can handle this. I love this forum!
|
Quote:
|
Got it, thanks again!
|
All times are GMT -5. The time now is 09:22 PM. |