Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Settings for apache-set user authentication for directories or files

Shulou Source: shulou.com Published: 2022-06-01 02:59:21 11月25日 Update

Set up user authentication for a directory or file

Add the following configuration to the corresponding CVM configuration file:

AllowOverride AuthConfig

AuthName "The administrator authentication!"

AuthType Basic

AuthUserFile / data/.htpasswd

Require valid-user

The path after Directory is the directory or file to be authenticated by the user, AuthName followed by a custom verification prompt, and AuthUserFile followed by a verification file.

Create a verification file using htpasswd, a tool that comes with apache:

# / usr/local/apache2/bin/htpasswd-cm / data/.htpasswd username

New password:

Re-type new password:

Adding password for user username

# cat / data/.htpasswd

Username:$apr1 $wLVEgNIh$Ne.IU7FgjfPBZsP6SocZ11

The parameter-c means to create a new file, and-m means to encrypt the password with MD5, followed by the path to the authentication file. Username is the user name.

# / usr/local/apache2/bin/apachectl-t

Syntax OK

Check that the configuration file is correct

# / usr/local/apache2/bin/apachectl graceful

Graceful means to reload the configuration file

Tags: File authentication configuration user directory trail path host information parameter password tool user name add encryption prompt check Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology Linux Docker vpn