Certificats/certify.sh
2024-05-13 18:45:49 +02:00

26 lines
902 B
Bash

#!/bin/bash
echo "Saisir le nom de domaine ?"
read domain
openssl genpkey -algorithm RSA -out ${domain}.key
echo "clé generate"
content="[req]\ndistinguished_name = req_distinguished_name\nreq_extasions = v3_req\nprompt = no\n\n[req_distinguished_name]\nC = FR\nST = Nord\nL = ROUBAIX\nO = Tips-Of-Mine\nOU = IT\nCN = Tips-Of-Mine.local\nmailAddress = admin@tips-of-mine.fr\n\n[v3_req]\nsubjectKeyIdentifier = @alt_names\n\n[alt_names]\nDNS.1=${domain}\n"
echo ${content} > ${domain}.cnf
echo "fichier cree"
openssl req -new -key ${domain}.key -out ${domain}.csr -config ${domain}.cnf
echo "CSR cree"
sshpass -p "root" scp ${domain}.csr root@10.0.4.3:etc/ssl/CA/"
echo "CSR transmit"
sleep 2
sshpass -p "root" scp ${domain}.conf root@10.0.4.3:etc/ssl/CA/"
echo "Config transmit"
sleep 3
echo "téléchargement"
wget https://10.0.4.3/certs/${domain}.crt -P /etc/ssl/private/localcerts/
sleep 4