Enabling basic authentication

Enabling basic authentication

  1. Run the following command:
    apt -y install apache2-utils
  2. Create a user account that has access to the server. Enter the following details:
    htpasswd -c /etc/apache2/.htpasswd <username> New password: Re-type new password: Adding password for user <username>
  3. Go to directory
    cd /etc/apache2/sites-enabled/
    .
  4. In
    nano openxpki.conf
    , add the following lines in
    <VirtualHost *: 443 block>
    :
    #HTTPS BASIC AUTH FOR LABELS Location /.well-known/est/*/simpleenroll AuthType Basic AuthName "estrealm" AuthUserFile /etc/apache2/.htpasswd require valid-user </Location> #HTTPS BASIC AUTH FOR NO LABEL <Location /.well-known/est/simpleenroll> AuthType Basic AuthName "estrealm" AuthUserFile /etc/apache2/.htpasswd require valid-user </Location>
  5. Add
    ErrorDocument 401 %{unescape:%00}
    before
    SSLEngine
    in the same virtual Host block.
    Example
    ServerAlias * DocumentRoot /var/www/ ErrorDocument 401 %{unescape:%00} SSLEngine On
  6. Restart the
    apache2 service
    using
    service apache2 restart
    .
    Basic authentication works using the above user name and password.