This command transfers the usenet directory to the rsync backup server... Now I need to set up rsync on the main file server.
sudo rsync -r --verbose ./usenet "sgoggin@10.1.1.100:/srv/ActiveData/TV Shows"
So How do I get rsync to connect using SSH and not prompt for password
http://troy.jdmz.net/rsync/index.html
-
On the client run the following commands:
$ mkdir -p $HOME/.ssh
This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P '' -
Copy $HOME/.ssh/id_dsa.pub to the server.
-
On the server run the following commands:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
Depending on the version of OpenSSH the following commands may also be required:
$ chmod 0600 $HOME/.ssh/authorized_keys2$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
An alternative is to create a link from authorized_keys2 to authorized_keys:
$ chmod 0600 $HOME/.ssh/authorized_keys$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys
-
On the client test the results by ssh'ing to the server:
$ ssh -i $HOME/.ssh/id_dsa server
-
(Optional) Add the following $HOME/.ssh/config on the client:
Host 10.1.1.100
This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.
IdentityFile ~/.ssh/id_dsa
So here is what I have on LEECHER in the SGOGGIN home directory
sgoggin@Leecher:~/.ssh$ ls
config keyFile keyFile.pub known_hosts
sgoggin@Leecher:~/.ssh$ cat config
Host 10.1.1.100
IdentityFile ~/.ssh/keyFile
the keyFiles were created with ssh-keygen -f ~/.ssh/keyFile -t dsa
This is the command to use
sudo rsync --recursive --verbose --stats -e "ssh -i /home/sgoggin/.ssh/keyFile" ./usenet "sgoggin@10.1.1.100:/srv/ActiveData/TV Shows"\And here is the script
#!/bin/sh
# /etc/cron.daily/standard: standard daily maintenance script
# Written by Ian A. Murdock
# Modified by Ian Jackson
# Modified by Steve Greenland
bak=/var/backups
LOCKFILE=/var/lock/cron.daily
LOGFILE=/var/log/rsyncbackup
umask 022
#
# Avoid running more than one at a time
#
if [ -x /usr/bin/lockfile-create ] ; then
lockfile-create $LOCKFILE
if [ $? -ne 0 ] ; then
cat <> $LOGFILE
# Directory to copy from on the source machine.
BACKDIR="/home/sgoggin/usenet"
# Directory to copy to on the destination machine.
DESTDIR="\"sgoggin@10.1.1.100:/srv/ActiveData/usenet\""
# Options.
# -n Don't do any copying, but display what rsync *would* copy. For testing.
# -a Archive. Mainly propogate file permissions, ownership, timestamp, etc.
# -u Update. Don't copy file if file on destination is newer.
# -v Verbose -vv More verbose. -vvv Even more verbose.
# See man rsync for other options.
OPTS="-n -recursive --verbose --stats -e \"ssh -i /home/sgoggin/.ssh/keyFile\" "
# May be needed if run by cron?
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
# Only run rsync if $DEST responds.
logger "TRANSFER - Starting rsync $OPTS $BACKDIR $DESTDIR"
rsync -recursive --verbose --stats -e "ssh -i /home/sgoggin/.ssh/keyFile" /home/sgoggin/usenet "sgoggin@10.1.1.100:/srv/ActiveData/usenet" >> $LOGFILE
# rsync $OPTS "$BACKDIR" "$DESTDIR"
# >> $LOGFILE
#
# Clean up lockfile
#
if [ -x /usr/bin/lockfile-create ] ; then
kill $LOCKTOUCHPID
lockfile-remove $LOCKFILE
fi
No comments:
Post a Comment