Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell script to generate self signed ssl unattended

I am like 95% done my shell script to install a Debian mail server from a fresh install, this is based on my currently running mailserver that I know to be working. What I have done is I have captured user input for the required info for the SSL but every time I try to generate the SSL unattended with openssl it fails. Any chance someone can help me? I have tried the following which works for mysql changes but didnt work for me.

openssl req -new -x509 -days 3650 -nodes -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem<<EOF
$country
$state
$city
$org
$unit
$commonname
$email
EOF

This gets me as far as this and then I have to hit enter... not cool as I need to not have to hit anything. Any ideas?

like image 238
John Stapleton Avatar asked Nov 22 '12 04:11

John Stapleton


People also ask

Which command do you use to create a self-signed certificate?

It's easy to create a self-signed certificate. You just use the openssl req command.


1 Answers

What I've used with SaltStack is:

openssl req -new -x509 -days 365 -nodes \
  -out /etc/ssl/certs/postfix.pem \
  -keyout /etc/ssl/private/postfix.pem \
  -subj "/C=RO/ST=Bucharest/L=Bucharest/O=IT/CN=www.example.ro"

Credit go to Sean P. Kane.

like image 96
Cristian VIDU Avatar answered Sep 17 '22 12:09

Cristian VIDU