Friday, January 11, 2013

htpasswd to protect a web pages

Lets say you have a have a smokeping services and you wish to protect it with a password. then you can use htpasswd to protect it.

First you need to cd to that folder
# cd  /opt/smokeping

then create a new htpasswd
and add user 'admin'
# htpasswd  -c /opt/smokeping/.htpasswd admin

If you have an existing htpasswd file, then you can just update it using
# htpasswd  /opt/smokeping/.htpasswd admin

after done, you need to enable this in the apache config
you need to add:


<Directory "/var/www/html/smokeping">

     AuthUserFile /opt/smokeping/.htpasswd
     AuthType Basic
     AuthName "Smokeping Admin Pages"
     Require valid-user

</Directory>


Then reload the Apache services


Tuesday, January 8, 2013

SSL cert

Generate the private key
# openssl genrsa -out myserver.key 2048

then generate the Certificate signing request (CSR) from the private key
# openssl req -new -key myserver.key -out myserver.csr

This key will be given to SSL authority to sign the cert and will return back a .crt file
After you get it, put it into apache server and append this into the httpd.conf


    SSLEngine On
    SSLCertificateKeyFile myserver.key
    SSLCertificateFile myserver.crt
    SSLCACertificateFile RapidSSL_CA_bundle.pem