Skip to content

Instantly share code, notes, and snippets.

@bensojona
Created April 13, 2015 16:34
Show Gist options
  • Save bensojona/74ed44e5518c7f371d9e to your computer and use it in GitHub Desktop.
Save bensojona/74ed44e5518c7f371d9e to your computer and use it in GitHub Desktop.
if [ -s "ssh_keys/$1-key.pem" ] && [ -s "ssh_keys/$1-key.pub" ]; then
echo Using existing $1-key pair...
else
echo No $1-key pair exists, generating new keys...
rm -rf ssh_keys/$1-key.pem
rm -rf ssh_keys/$1-key.pub
openssl genrsa -out ssh_keys/$1-key.pem 1024
chmod 400 ssh_keys/$1-key.pem
ssh-keygen -y -f ssh_keys/$1-key.pem > ssh_keys/$1-key.pub
echo ssh_keys/$1-key.pem contents...
cat ssh_keys/$1-key.pem
echo ssh_keys/$1-key.pub contents...
cat ssh_keys/$1-key.pub
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment