Skip to content

Instantly share code, notes, and snippets.

@dindinw
Created February 27, 2014 05:34
Show Gist options
  • Save dindinw/9244949 to your computer and use it in GitHub Desktop.
Save dindinw/9244949 to your computer and use it in GitHub Desktop.
#!/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