cryptsetup - setup cryptographic volumes for
dm-crypt (including LUKS extension)
--下面我在虚拟机上测试,新加一个盘,分成/dev/sdb1,不格式化
[root@localhost ~]# cryptsetup luksFormat /dev/sdb1
WARNING!
========
This will overwrite data on /dev/sdb1 irrevocably.
Are you sure? (Type uppercase yes): YES --要大写的YES
Enter LUKS passphrase:
Verify passphrase:
[root@localhost ~]# cryptsetup luksOpen /dev/sdb1 secretdisk --这里是把这个加密磁盘做一个映射,后面的secretdisk这个名字自定义
Enter passphrase for /dev/sdb1: --输入上一步设定的密码
[root@localhost ~]# ls /dev/mapper/secretdisk --就会产生这个设备文件
/dev/mapper/secretdisk
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1 --算法选择默认的1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) --密钥长度,越长越安全,但加密和解密消耗的资源和时间也较长
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 1 --密钥过期时间,我这里选择1天是为了方便后面测试
Key expires at Fri 09 Oct 2015 11:35:11 AM CST
Is this correct? (y/N) y
GnuPG needs to construct a user ID to identify your key.
Real name: haha
Name must be at least 5 characters long
Real name: hahahehe
Email address: hahahehe@126.com
Comment: @_@
You selected this USER-ID:
"hahahehe (@_@) <hahahehe@126.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
# gpg2 --verify mediawiki-1.25.2.tar.gz.sig mediawiki-1.25.2.tar.gz
gpg: Signature made Tue 11 Aug 2015 05:27:49 AM CST using RSA key ID 23107F8A
gpg: Can't check signature: No public key
--这个验证签名,但结果是报:不能检测签名,没有public key的错误
# gpg2 --import mediawiki_pubkey.txt --导入mediawiki的公钥
# gpg2 --verify mediawiki-1.25.2.tar.gz.sig mediawiki-1.25.2.tar.gz
gpg: Signature made Tue 11 Aug 2015 05:27:49 AM CST using RSA key ID 23107F8A
gpg: Good signature from "Chad Horohoe <chad@wikimedia.org>"
gpg: aka "keybase.io/demon <demon@keybase.io>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 41B2 ABE8 17AD D3E5 2BDA 946F 72BC 1C5D 2310 7F8A
2,使用rpm版的ssl创建证书和密钥
# cd /etc/pki/tls/certs/
# make httpd.crt --证书名字可以随意写,扩展名用crt(不一定)
umask 77 ; \
/usr/bin/openssl genrsa -des3 1024 > httpd.key
Generating RSA private key, 1024 bit long modulus
....................++++++
.........................++++++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase: --两次密码,自己设定,以后有用
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key httpd.key -x509 -days 365 -out httpd.crt -set_serial 0
Enter pass phrase for httpd.key: --自动创建私钥,输密码
Country Name (2 letter code) [GB]:cn
State or Province Name (full name) [Berkshire]:guangdong
Locality Name (eg, city) [Newbury]:shenzhen
Organization Name (eg, company) [My Company Ltd]:haha
Organizational Unit Name (eg, section) []:it
Common Name (eg, your name or your server's hostname) []:li.cluster.com
Email Address []:li@126.com
4,重启apache
# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: Apache/2.2.3 mod_ssl/2.2.3 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.
Server localhost.localdomain:443 (RSA)
Enter pass phrase: --输入创建证书时的密码
OK: Pass Phrase Dialog successful.
[ OK ]
# netstat -ntlup |grep httpd
tcp 0 0 :::80 :::* LISTEN 5821/httpd
tcp 0 0 :::443 :::* LISTEN 5821/httpd
--如果启不起来,报443被占用,很有可能是你的vmware-workstation-server服务是开启状态
解决方法:
service vmware-workstation-server stop
chkconfig vmware-workstation-server off
# vim /etc/dovecot/conf.d/10-ssl.conf
ssl_cert = </etc/pki/tls/certs/postfix.pem
ssl_key = </etc/pki/tls/certs/postfix.pem --两个<符号不能去掉
# vim /etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u
# /etc/init.d/dovecot restart
5,配置dns支持邮件交换
yum install bind* -y
# vim /etc/named.conf
listen-on port 53 { any; };
allow-query { any; };
zone "cluster.com" IN {
type master;
file "data/master.cluster.com.zone";
};
# vim /var/named/data/master.cluster.com.zone
$TTL 86400
@ IN SOA sdfssf.sfas.com. root. (
2015100801
60
30
360
86400 )
IN NS 10.1.1.7.
IN MX 0 10.1.1.7.
mail IN A 10.1.1.7
# /etc/init.d/named restart
ip tunnel add tun0 mode gre remote 10.1.1.9 local 10.1.1.7
ip link set tun0 up
ip addr add 3.3.3.3 peer 3.3.3.4 dev tun0
ip route add 2.2.2.0/24 dev tun0
ip tunnel add tun0 mode gre remote 10.1.1.7 local 10.1.1.9
ip link set tun0 up
ip addr add 3.3.3.4 peer 3.3.3.3 dev tun0
ip route add 1.1.1.0/24 dev tun0