Skip to content

Instantly share code, notes, and snippets.

@lebowitz
Created July 20, 2013 02:07
Show Gist options
  • Save lebowitz/6043546 to your computer and use it in GitHub Desktop.
Save lebowitz/6043546 to your computer and use it in GitHub Desktop.
#!/bin/sh
USERNAME="cal"
if test -z $1
then
echo "you must specify a hostname or ip address as the first argument"
exit 1
fi
key=`cat ~/.ssh/id_dsa.pub`
ssh $USERNAME@$1 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo \"$key\" >> ~/.ssh/authorized_keys && chmod 644 ~/.ssh/authorized_keys"
if [ $? = "0" ]; then
echo "key copy successful"
else
echo "key copy failed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment