Created
December 14, 2011 15:23
-
-
Save mjuneja/1477004 to your computer and use it in GitHub Desktop.
Shell script to get my public key from a url and append to authorized_keys to grant access
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 | |
if [ ! -d $HOME/.ssh ]; then | |
`mkdir $HOME/.ssh` | |
`touch $HOME/.ssh/authorized_keys` | |
`chmod 0600 $HOME/.ssh/authorized_keys` | |
else | |
if [ ! -d $HOME/.ssh/authorized_keys ]; then | |
echo "Creating authorized_keys file" | |
`touch $HOME/.ssh/authorized_keys` | |
`chmod 0600 $HOME/.ssh/authorized_keys` | |
fi | |
fi | |
#get public key from a public url, mine is at dropbox | |
PATH_TO_KEY="http://dl.dropbox.com/u/628209/manik.pub" | |
echo `wget $PATH_TO_KEY` | |
#todo - handle failure to get key | |
key=`echo $PATH_TO_KEY | sed 's_.*/__' ` | |
`cat $key >> $HOME/.ssh/authorized_keys` | |
`rm $key` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment