public
Last active

A version of ssh-copy-id for the .bashrc file on your Mac.

  • Download Gist
.zshrc
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
ssh-copy-id() {
USER=$(whoami)
USAGE="Usage: `basename $0` [-i FILE] user@host"
FILE="$HOME/.ssh/id_rsa.pub"
 
if [ $# -lt 1 ]; then
echo "$USAGE"
fi
 
 
while getopts “i::” OPTION; do
case $OPTION in
i)
FILE=$OPTARG
;;
?)
echo "$USAGE"
;;
esac
done
shift $OPTIND-1
 
cat $FILE | ssh $1 "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"
}

Might want to use $HOME instead of /Users/$USER, that'll be more portable.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.