HTTPD access control and CGI for file-based users in Linux

Source: Internet
Author: User

Based on user access control (this control is the entire page control)
User authentication type:
Basic certification: Essential
Abstract Certification: Digest, whether plaintext or ciphertext control.


Virtual User: A credential that is used only to access a service and obtain resources:
User account password location:. htpasswd This file user name is plaintext and the password is encrypted. The name of this file is also your own, generally we do not change. htpasswd stored under HTTPD configuration file

Example: We have a document-based authentication (certificate of account and password for the file storage account)
(1) Edit the configuration file to authenticate the directory to do user authentication
</directory "/var/www/ning/liang" >-----Specify the directory to be certified
Options none------don't specify any option
AllowOverride authconfig-----Allow coverage, authentication is typically enabled for Authconfig, stating that authentication-related configuration is done
AuthType Basic-----------Specify authentication type
AuthName "Admin area." -----The user to explain the information, is to enter the password to let users know why certification.
Authbasicprovider file------Specifies what the authentication mechanism is, default is file (can be omitted)
AUTHUSERFILE/ETC/HTTPD/CONF/.HTPASSWD------Specifies the file that holds the authenticated user and password. (We need to create it ourselves)
Require valid-user-----------Valid-uer All eligible users can log in,
</Directory>
Individual user-specified formats such as: Require user ning Hong----Two users separated by spaces


(2) Create an authentication file. HTPASSWD (the account here is clear, the password is encrypted, generally we do not manually edit, with tools generated)
Tools to generate authentication files:
htpasswd
C: If this file does not exist beforehand, create; note: can only be used when creating the first user;
-M: Store user's password information in MD5 format
-D: Delete the specified user
#htpasswd-C-m/etc/httpd/conf/.htpasswd Tom-----No. htpasswd file first created with-C,-M encryption, specify the path, and enter the user name
New Password:-----Enter the user's password
Re-type New Password:
Adding Password for user Tom
#htpasswd-M/etc/httpd/conf/.htpasswd Qing-------There is no need to create. htpasswd, add it directly.
#cat/etc/httpd/conf/.htpasswd
Tom: $apr 1$o3hnsazw$rxclvyixdntnzorgji3qd.------The password is encrypted with MD5.
Qing: $apr 1$tliarc5b$pfnepkddemcxlrbbnnnim.
# htpasswd-d/etc/httpd/conf/.htpasswd Qing-----Delete User Qing
Deleting Password for user Qing
# cat/etc/httpd/conf/.htpasswd----------View the results of the deletion
Tom: $apr 1$o3hnsazw$rxclvyixdntnzorgji3qd.


(3) Group file authentication
</directory "/var/www/ning/liang" >-----Specify the directory to be certified
Options none------don't specify any option
AllowOverride authconfig-----Allow coverage, authentication is typically enabled for Authconfig, stating that authentication-related configuration is done
AuthType Basic-----------Specify authentication type
AuthName "Admin area." -----The user to explain the information, is to enter the password to let users know why certification.
Authbasicprovider file------Specifies what the authentication mechanism is, default is file (can be omitted)
AUTHUSERFILE/ETC/HTTPD/CONF/.HTPASSWD------Specifies the file that holds the authenticated user and password. (We need to create it ourselves)
Authgroupfile/etc/httpd/conf/.htgroup-------Specify user group files (we need to create them ourselves)
Require Group Test-----------the specified set name
</Directory>

Create an edit group file
Group file format: Group name: User1 user2 User3
#vim/etc/httpd/conf/.htgroup----Create the. Htgroup Group certification file content is as follows
Test:tom Ning--------Group named Test user is Tom, ning


Self-test can: Do not explain again, note that the browser generates records.

Browser: Http://www.ning.com/liang

CGI script----Universal Gateway Interface

    scriptalias/cgi-bin/"/var/www/cgi-bin/"------------ Specify the CGI alias

     

  instance: Create ning.sh script in Directory/cgi-bin/directory (default system is bash parsing supported)
        #!/bin/bash
        #
         cat << EOF
        content-type: text/html

        <pre>
         The hostname is: $ (hostname).
        The date is: $ (date).
        The IP is: $ (ifconfig)

        </pre>
        EOF

Enter on browser: 172.16.3.20/cgi-bin/ning.sh

650) this.width=650; "Style=" border-bottom:0px; border-left:0px; border-top:0px; border-right:0px "title=" image "border=" 0 "alt=" image "src=" http://img1.51cto.com/attachment/201408/10/1384120_ 1407678856dddh.png "" 539 "height=" 429 "/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.