Friday, January 10, 2014

Sshkey install update.

Wrote a script a while back to put your ssh key on a remote system so you do not have to type in the password all the time. Found a few shortcomings with it and now have updated it. You will have to type in your password to login and complete the script process.

# invoke with ./ servername

# set up the .ssh dir if it does not exist
ssh $1 'if [ ! -d "$DIRECTORY" ];  then  mkdir $DIRECTORY ;chmod 700 $DIRECTORY ; fi'

# copy the key
scp $DIRECTORY/ $1:~/.

# install the key
ssh $1 'cat >> $DIRECTORY/authorized_keys'
ssh $1 'chmod 600 $DIRECTORY/authorized_keys '

# remove the public key you just copied
ssh $1 'rm ~/'

No comments:

Post a Comment