Files
homelab-scripts/csr.sh
2018-01-07 21:35:42 -05:00

38 lines
643 B
Bash

#!/bin/bash
if [ $# -eq 0 ]; then
read -p 'Please enter a Hostname: ' HOSTNAME
elif [ $# -gt 0 ]; then
# do something more here
else
HOSTNAME=$1
fi
DOMAIN="home.johnhagunt.com"
openssl req -new -sha512 -nodes -out $HOSTNAME.$DOMAIN.csr -newkey rsa:4096 -keyout $HOSTNAME.$DOMAIN.key -config <(
cat <<-EOF
[req]
default_bits = 4096
prompt = no
default_md = sha512
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C=US
ST=PA
L=Pittsburgh
O=Gaunt
OU=Gaunt
emailAddress=admin@johnhgaunt.com
CN=$HOSTNAME.$DOMAIN
[ req_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = $HOSTNAME.$DOMAIN
DNS.2 = $HOSTNAME
EOF
)