Created
February 27, 2014 05:34
-
-
Save dindinw/9244949 to your computer and use it in GitHub Desktop.
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/bash | |
function installDSAKeysOnTarget() { | |
TARGET=$1 | |
if [ ! -f $HOME/.ssh/id_dsa.pub ]; then | |
ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P '' | |
fi | |
PUBKEY=`cat $HOME/.ssh/id_dsa.pub` | |
AUTH2_FILE='~/.ssh/authorized_keys2' | |
# Setup the remote machine so that this node can log into it without error$ | |
ssh -o StrictHostKeychecking=no root@$TARGET "mkdir -p ~/.ssh; chmod 0700 ~/.ssh; if [ -z \"\$(grep \"$PUBKEY\" $AUTH2_FILE 2>/dev/null)\" ]; then echo $PUBKEY >> $AUTH2_FILE ; chmod 0644 $AUTH2_FILE; fi" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment