From Stack Overflow
Jump to: navigation, search Pushes your ssh public key to a server for passwordless authentication

if [ -z "$1" ]; then
	echo " by Brian Enigma <>"
	echo "Function: copies ssh public keys to remote machines for passwordless login"
	echo "Usage: <username>@<servername or ip address>"
	exit 1
CONTENT=`cat ~/.ssh/$KEY`
echo "Attaching key to authorized_keys file"
ssh $1 "mkdir -p .ssh && chmod 700 .ssh && touch .ssh/$STORE \
	&& chmod 644 .ssh/$STORE \
	&& echo '$CONTENT' >> .ssh/$STORE"
echo "Complete!  You should be able to log in without a password now!"