Created
April 24, 2015 21:22
-
-
Save egroeper/2d604c53408bfe1172a9 to your computer and use it in GitHub Desktop.
ssh-copy-pubkey BASH function for .bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ssh-copy-pubkey <keyfile.pub> [user@]host | |
# this one avoids duplicates (stupid version by using fgrep, should only check pubkey part, not comments) | |
ssh-copy-pubkey() { | |
export PUBKEYTOCOPY=$(cat $1); ssh $2 "mkdir -p .ssh ; touch .ssh/authorized_keys ; if ! fgrep -q \"$PUBKEYTOCOPY\" .ssh/authorized_keys ; then echo $PUBKEYTOCOPY >> .ssh/authorized_keys; fi"; unset PUBKEYTOCOPY | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment