Wednesday, November 17, 2010

Script Ready (Essentially)

Monday and Tuesday I worked on getting key based authentication ssh. I had to generate a private and public key on the source machine using ssh-keygen. You have to copy the pubkey from the source to the target and in the sshd config enable key based authentication (In Ubuntu it seems to be on by default). Once that is done you can ssh in from the account that created the key into the account that holds the pubkey.

So Wednesday Matt helped me with rsync. The two echo commands are from another script I found on the internets. As you can see the the script runs the rsync command and makes a log of what happened and appends the date to it. I included comments with what the parameters do since there are so many.

#!/bin/bash

echo $’\n\n’ >> rsync.log
rsync -avzogtph /home/sysadmin/stuff/ sysadmin@192.168.125.101:/home/sysadmin/backup/
echo “Completed at: `/bin/date`” >> $LOGFILE

#-a archive mode
#-v verbose
#-z compress
#-o preserve owner (super-user only)
#-g preserve group
#-t modification times
#-p preserve permissions
#-h human readable

I will talk to Devin about getting it set up.

1 comment:

  1. Nice post! This is a short (and sweet) primer on using rsync. I would want to refer back to it in the future.

    With that in mind - please change the title of the post to something like "Using rsync" so that this will be easier to locate down the road.

    ReplyDelete