Skip to content

Instantly share code, notes, and snippets.

@brenttheisen
Last active August 29, 2015 13:58
Show Gist options
  • Save brenttheisen/10233686 to your computer and use it in GitHub Desktop.
Save brenttheisen/10233686 to your computer and use it in GitHub Desktop.
Script to generate a host key and CSR file when keying a SSL certificate.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: `basename $0` domain"
exit 85
fi
DOMAIN=$1
HOST_KEY="$DOMAIN".key
CSR="$DOMAIN".csr
PRIVATE_KEY="$DOMAIN".private.key
set -o verbose
set -e
openssl genrsa -des3 -out "$HOST_KEY" 2048
openssl req -new -key "$HOST_KEY" -out "$CSR"
openssl rsa -in "$HOST_KEY" -out "$PRIVATE_KEY"
echo
echo "Now copy and paste this CSR to your CA..."
echo
cat "$CSR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment