Last active
August 29, 2015 14:23
-
-
Save danielzen/77cc4c6f60bbe5dc5f8a to your computer and use it in GitHub Desktop.
ssh-copy-pub: simpler version of ssh-copy-id for copying employee/contractor public keys to remote server authorized_keys file
This file contains 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
#!/bin/sh | |
display_usage() { | |
echo "This script must be run with at least 2 arguments." | |
echo "\nUsage:\n$0 pubKeyFile {ssh arguments}\n" | |
echo "Example: ssh-copy-pub john_rsa.pub [email protected]\n" | |
} | |
if [ $# -lt 2 ] | |
then | |
display_usage | |
exit 1 | |
fi | |
pubKeyFile=$1; shift | |
cat $pubKeyFile | ssh "$@" 'cat >> .ssh/authorized_keys && echo "Key copied"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would like to
mkdir -pm 700 .ssh &&
before the cat, but can't break the pipe....