Found this nice script for the purpose, i thought i would share
#/bin/sh
# RSA keys may be subject to export restrictions
if [ ! -n "$1" ]
then
echo "Usage: `basename $0`
[email protected]"
exit
fi
if [ ! -e ~/.ssh/id_rsa.pub ]
then
echo "Generating RSA key"
ssh-keygen -t rsa
fi
echo "Copying local SSH pub_key to $1"
echo "Please enter password for remote account:"
# Use scp to opy key to remote temp file
scp ~/.ssh/id_rsa.pub $1:~/.ssh/authorized_keys.tmp
# Append key to ~/.ssh/authorized_keys
echo "Please enter password again to append key to remote 'authorized_keys' file"
ssh $1 "cat ~/.ssh/authorized_keys.tmp >> ~/.ssh/authorized_keys; rm ~/.ssh/authorized_keys.tmp; exit"