Skip to content

Instantly share code, notes, and snippets.

@slumos
Created May 2, 2011 20:33
Show Gist options
  • Select an option

  • Save slumos/952300 to your computer and use it in GitHub Desktop.

Select an option

Save slumos/952300 to your computer and use it in GitHub Desktop.
#! /bin/zsh
function usage {
echo "usage: $0 pubkey host"
exit 1
}
if [[ $# -ne 2 ]]; then
usage
fi
pubkey=$1
host=$2
ssh $host 'test -d $HOME/.ssh || mkdir -m 0700 $HOME/.ssh && test -f $HOME/.ssh/authorized_keys || touch $HOME/.ssh/authorized_keys && test -L $HOME/.ssh/authorized_keys2 || rm -f $HOME/.ssh/authorized_keys2 && ln -fs $HOME/.ssh/authorized_keys $HOME/.ssh/authorized_keys2 && cat >>$HOME/.ssh/authorized_keys' <$pubkey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment