Tuesday, November 6, 2012

Quick and easy self signed SSL certificates

So, there are many answers for that, but this one worked best for me:

First thing first, prerequisites:

yum install mod_ssl openssl nc -y
Now for the certificates, note that 'Common Name' is the most important field, where you put your site's FQDN:
cd ~/
mkdir ssl
cd ssl
openssl genrsa -out server.key 1024
openssl req -new -key server.key -out server.csr

You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:
State or Province Name (full name) [Berkshire]:
Locality Name (eg, city) [Newbury]:
Organization Name (eg, company) [My Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
mkdir -p  /etc/ssl/certs
mkdir -p  /etc/ssl/private
sudo cp server.crt /etc/ssl/certs/self_signed.crt
sudo cp server.key /etc/ssl/private/self_signed.key

In apache:
SSLEngine on
SSLCertificateFile /etc/ssl/certs/self_signed.crt
SSLCertificateKeyFile /etc/ssl/private/self_signed.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog logs/ssl_request_log \
   "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Thursday, November 1, 2012

Creating multiple users at once

 So you need to create a bunch of standardized users for whatever reason and you need them 10 minutes ago?

for username in user_one user_two user_three; \
do useradd -m -G user_group ${username}; \
echo -e "user_password\nuser_password"|passwd --stdin ${username]; \
mkdir /home/${username}/some_folder; \
chown -R ${username}:${username} /home/${username}; \
done