#!/bin/bash echo "Enter your ip address (Leave blank to use external IP):" read myip sudo apt update if [$myip=""] then $myip="$(dig +short myip.opendns.com @resolver1.opendns.com)" fi directory="$(pwd)" echo "Creating keys..." openssl ecparam -genkey -name secp384r1 -out privkey.pem openssl ec -in privkey.pem -noout -text echo "Writing config file..." echo "[ req ] prompt = no encrypt_key = no default_md = sha256 distinguished_name = dname req_extensions = reqext [ dname ] CN = ${myip} emailAddress = admin@example.com [ reqext ] subjectAltName = IP:${myip}" > "openssl.cnf" echo "Creating signing request..." openssl req -new -config openssl.cnf -key privkey.pem -out csr.pem echo "Creating certificate..." openssl x509 -req -in csr.pem -signkey privkey.pem -out certificate.crt -days 365 echo "Done"