[root@localhost conf]# htpasswd -c -m .htpasswd star
New password:
Re-type new password:
Adding password for user star
[root@localhost conf]# htpasswd -m .htpasswd tom
New password:
Re-type new password:
Adding password for user tom 只有第一次创建文件要用到-c。
AuthType Basic
AuthName "Enter your Access"
AuthUserFile "conf/.htpasswd"
AuthGroupFile "conf/.htgroup"
Require group grp
Require ip 172.16.40.1
php里面改一下:
pm.status_path = /status-php
这里再贴一下CA的过程。
私有CA:
ca的配置文件:/etc/pki/tls/openssl.cnf 在lamp1中已经介绍了,这里就不多说了。
当前目录:/etc/pki/CA
[root@localhost CA]# (umask 077;openssl genrsa -out private/cakey.pem 4096) #生成CA的私钥:
[root@localhost CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem #生成自签证书,也做根证书,证书链
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) [XX]:CN
State or Province Name (full name) []:BEIJING
Locality Name (eg, city) [Default City]:BEIJING
Organization Name (eg, company) [Default Company Ltd]:LinuxOPS
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:ca.star.com
Email Address []:
[root@localhost CA]#
[root@localhost CA]# touch serial
[root@localhost CA]# echo 00 > serial
[root@localhost CA]# touch index.txt
HTTPD:
[root@localhost httpd]# pwd
/etc/httpd
[root@localhost httpd]# mkdir ssl
[root@localhost httpd]# (umask 077;openssl genrsa -out ssl/myadm.key 2048) #生成私钥
Generating RSA private key, 2048 bit long modulus
..........................................................................................+++
............................+++
e is 65537 (0x10001)
[root@localhost httpd]# openssl req -new -key ssl/myadm.key -out /tmp/myadm.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) [XX]:CN
State or Province Name (full name) []:BEIJING
Locality Name (eg, city) [Default City]:BEIJING
Organization Name (eg, company) [Default Company Ltd]:LinuxOPS
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:myadm.star.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []: 把证书申请发给CA。
[root@localhost httpd]# scp /tmp/myadm.csr 172.16.40.20:/tmp/
root@172.16.40.20's password:
myadm.csr 100% 1009 1.0KB/s 00:00
[root@localhost httpd]# 如果没有scp命令,要安装openssh-clients包。两边都要有这个命令。
CA:
ca签署:
[root@localhost CA]# openssl ca -in /tmp/myadm.csr -out certs/myadm.crt
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 0 (0x0)
Validity
Not Before: Jan 26 09:38:33 2016 GMT
Not After : Jan 25 09:38:33 2017 GMT
Subject:
countryName = CN
stateOrProvinceName = BEIJING
organizationName = LinuxOPS
organizationalUnitName = Ops
commonName = myadm.star.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
9D:FD:70:BD:97:BB:BB:E4:61:55:7B:6C:BA:B2:FD:B6:93:DC:8E:EC
X509v3 Authority Key Identifier:
keyid:AA:DA:31:1A:3F:5B:F3:D5:D2:0C:93:4E:37:78:9B:38:E6:C8:FB:26
Certificate is to be certified until Jan 25 09:38:33 2017 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[root@localhost CA]# 把证书传回给HTTPD:
[root@localhost CA]# scp certs/myadm.crt 172.16.40.40:/etc/httpd/ssl/
The authenticity of host '172.16.40.40 (172.16.40.40)' can't be established.
RSA key fingerprint is ec:8e:a7:90:97:03:2c:e4:78:d8:04:98:7d:9a:59:1c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.40.40' (RSA) to the list of known hosts.
root@172.16.40.40's password:
myadm.crt 100% 5714 5.6KB/s 00:00
[root@localhost CA]#