Created
July 12, 2010 14:00
-
-
Save cwage/472495 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
if [ $# -ne 2 ] | |
then | |
echo "Usage: $0 <server> <key>" | |
exit 1 | |
fi | |
WHERE=$1 | |
KEY=$2 | |
# If we have an ssh public key, let's make sure our remote host has it. | |
if [ -f ~/.ssh/$KEY.pub ]; then | |
cat ~/.ssh/$KEY.pub | ssh $WHERE ' | |
WHERE=`mktemp /tmp/key.XXXXXXXX`; | |
cat > $WHERE; | |
if [ ! -d ~/.ssh/ ]; then | |
mkdir ~/.ssh/; | |
fi | |
if [ ! -f ~/.ssh/authorized_keys ]; then | |
cp $WHERE ~/.ssh/authorized_keys; | |
else | |
cat $WHERE ~/.ssh/authorized_keys | sort | uniq > ~/.ssh/authorized_keys; | |
fi | |
chmod -R og-rwx ~/.ssh; | |
rm -rf $WHERE;' | |
fi | |
# Copy over our files, as well as this script | |
ssh $WHERE ' | |
if [ ! -d ~/bin ]; then | |
mkdir ~/bin | |
fi' | |
scp ~/bin/assimilate.sh $WHERE:~/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment