Last active
July 8, 2019 04:04
-
-
Save initialed85/bd7fff524a6c42efa35de33218075487 to your computer and use it in GitHub Desktop.
Create a public key for an AWS private key
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 | |
# props to original at https://gist.github.com/zircote/1243501 | |
if [[ "${1}" == "" ]]; then | |
echo "usage: ${0} some_private_key.pem" | |
echo "" | |
echo "The result will be a public key at $(pwd)/some_private_key.pub" | |
exit 1 | |
fi | |
PRIVATE=${1} | |
BASE=$(basename -s .pem ${PRIVATE}) | |
PUBLIC=${BASE}.pub | |
if [[ -e ${PUBLIC} ]]; then | |
echo "error: public key ${PUBLIC} already exists" | |
exit 1 | |
fi | |
ssh-keygen -y -f ${PRIVATE} > ${PUBLIC} | |
if [[ ${?} -ne 0 ]]; then | |
rm -fr ${PUBLIC} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment