Last active
August 29, 2015 14:08
-
-
Save emlun/e6d4059b8f3f6947aef3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
FILENAME="device" | |
KEY_FILE="${FILENAME}.key" | |
REQUEST_FILE="${FILENAME}.csr" | |
CERT_FILE="${FILENAME}.crt" | |
UPLOAD_FILE="tmp/${REQUEST_FILE}" | |
DOWNLOAD_FILE="tmp/${CERT_FILE}" | |
CA_HOST=home | |
CA_HOST_CACERT_FILE="/etc/ssl/public/mimer-root-CA.crt" | |
CA_HOST_CA_KEY_FILE="/etc/ssl/private/mimer-root-CA.key" | |
trap 'exit $?' ERR | |
touch "${KEY_FILE}" | |
chmod 600 "${KEY_FILE}" | |
openssl req -newkey rsa:2048 -keyout "${KEY_FILE}" -out "${REQUEST_FILE}" -nodes | |
scp "${REQUEST_FILE}" "mimer:${UPLOAD_FILE}" | |
ssh -t "${CA_HOST}" sudo openssl x509 -req -in "'${UPLOAD_FILE}'" -CA "'${CA_HOST_CACERT_FILE}'" -CAkey "'${CA_HOST_CA_KEY_FILE}'" -out "'${DOWNLOAD_FILE}'" -days 365 | |
scp "${CA_HOST}":"${DOWNLOAD_FILE}" "${CERT_FILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment