diff --git a/csr.sh b/csr.sh index b3e9ff9..a5198ac 100644 --- a/csr.sh +++ b/csr.sh @@ -1,38 +1,37 @@ #!/bin/bash - if [ $# -eq 0 ]; then - read -p 'Please enter a Hostname: ' HOSTNAME + read -p 'Please enter a Hostname: ' HOSTNAMES elif [ $# -gt 0 ]; then - # do something more here -else - HOSTNAME=$1 + HOSTNAMES=$@ 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 -) \ No newline at end of file +for i in $HOSTNAMES; do + openssl req -new -sha512 -nodes -out $i.$DOMAIN.csr -newkey rsa:4096 -keyout $i.$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=$i.$DOMAIN + + [ req_ext ] + subjectAltName = @alt_names + + [ alt_names ] + DNS.1 = $i.$DOMAIN + DNS.2 = $i + EOF + ) +done \ No newline at end of file