Recently got tired of having bookmarks on my my laptop and not on my desktop, podcasts on my desktop but not on my laptop and so on and so forth. So, I decided to use rsync to sync the two. I use my laptop most, so I started with that. I didn’t want to rsync my entire /home/user/ directory, so I just chose to sync the apps that I wanted to be the same on both computers. So, I just wrote a simple bash script to sync the two. First, I got rid of the passwords when I rsync or ssh to the desktop. I used the command below.

ssh-keygen -t rsa

Do not enter password when prompted. from there,

cd ~/.ssh/ && cp id_rsa.pub laptop.key

Then put that key into authorized_key file on the remote computer. I had an nfs share of my home computer, so I just did it that way. You could use FTP, Thumbdrive, etc.

cat laptop.key >> authorized_keys

Once that is complete, repeat for both machines. You should then have 2 way passwordless communication via rsync & ssh.

here’s the script I wrote.

#-------------------------------
# Laptop / Desktop sync script
#
# gi_james@strickstuff.com
#-------------------------------

# Declare Variables
amark="/home/james/.kde3.5/share/apps/amarok/"
kopet="/home/james/.kde3.5/share/apps/kopete/"
firefx="/home/james/.mozilla/"
thunder="/home/james/.thunderbird/"
school="/home/james/school/"

# Begin sync ops
echo "Syncing Amarok"
rsync -arvuz $amark compaq:$amark
echo "Syncing Firefox"
rsync -arvuz $firefx compaq:$firefx
echo "Syncing Thunderbird"
rsync -arvuz $thunder compaq:$thunder
echo "Syncing Kopete"
rsync -arvuz $kopet compaq:$kopet
echo "Syncing School Folder"
rsync -arvuz $school compaq:$school

echo " "
echo " "
echo " "
echo "DONE!!!!!!!!!!!!!"

This script will sync the directories in the #delare variables section. Change those around accordingly. I know there are other methods, but this method is good enough for what I want to do. Please feel free to email me with a better method. I’m certainly not the most proficient bash scripter.

Oh, one more thing, before I started, I edited /etc/hosts and added the hostname of all computers on my network. That way, all I have to do is type ssh computername instead of ssh ipaddy and no password is needed.