歡迎您光臨本站 註冊首頁

linux23-postfix

←手機掃碼閱讀     火星人 @ 2014-03-08 , reply:0

ssl 安全套接層


sendmail tls = smtps

[root@station245 /]# yum install sendmail* m4 dovecot -y


[root@station245 ~]# cd /etc/pki/tls/certs/

[root@station245 certs]# make sendmail.pem --生成密鑰,寫上相關信息

Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:guangdong
Locality Name (eg, city) [Newbury]:shenzheng
Organization Name (eg, company) [My Company Ltd]:uplooking
Organizational Unit Name (eg, section) []:it
Common Name (eg, your name or your server's hostname) []:station245
Email Address []:sdfasfa@gmail.com

[root@station245 /]# vim /etc/mail/sendmail.mc --修改sendmail主配置文件,打開下面五名的註釋,注意要頂格

define(`confCACERT_PATH', `/etc/pki/tls/certs')dnl
define(`confCACERT', `/etc/pki/tls/certs/ca-bundle.crt')dnl
define(`confSERVER_CERT', `/etc/pki/tls/certs/sendmail.pem')dnl
define(`confSERVER_KEY', `/etc/pki/tls/certs/sendmail.pem')dnl

DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl


DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl --並修改這句,監聽所有

[root@station245 /]# /etc/init.d/sendmail restart --重啟sendmail

===============================================================

pop3 tls = pop3s (埠995)

[root@station245 /]# vim /etc/dovecot.conf

protocols = pop3 pop3s

ssl_cert_file = /etc/pki/tls/certs/sendmail.pem
ssl_key_file = /etc/pki/tls/certs/sendmail.pem

[root@station245 /]# /etc/init.d/dovecot restart


===============================================================

[root@station245 /]# yum install bind* -y

[root@station245 /]# vim /var/named/chroot/etc/named.conf


options {
directory "/var/named";


};

zone "cluster.com" IN {
type master;
file "data/master.cluster.com.zone";
};

[root@station245 /]# vim /var/named/chroot/var/named/data/master.cluster.com.zone


$TTL 86400
@ IN SOA station245.cluster.com. root. (
2010111401
240
360
120
86400 )
IN NS station245.cluster.com.
IN MX 0 station245.cluster.com.
station245 IN A 10.1.1.245


[root@station245 /]# /etc/init.d/named restart

=============================================================

驗證:使用outlook驗證,注意windows要把DNS指向10.1.1.245,
在賬號-屬性-高級-把發送和接收的 此伺服器要求安全連接SSL 兩個選項打勾

使用mutt驗證
[user2@station245 ~]$ mutt -f pops://user1@station245.cluster.com


使用claws-mails驗證:

賬號設置-SSL- 選擇用SSL進行POP3連接和用SSL進行SMTP連接

然後發送郵件和接收郵件,會有證書的選項,選擇接受保存就可以收發郵件了

-----------------------------------------------------------------


http ssl = https (埠443)


[root@station245 /]# yum install openssl-* -y

[root@station245 /]# openssl req -new > station245.cluster.com
Generating a 1024 bit RSA private key
..
.........................................
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase: --輸入兩次密碼

Country Name (2 letter code) [GB]:CN


State or Province Name (full name) [Berkshire]:guangdown
Locality Name (eg, city) [Newbury]:shenzhen
Organization Name (eg, company) [My Company Ltd]:upl
Organizational Unit Name (eg, section) []:it
Common Name (eg, your name or your server's hostname) []:li
Email Address []:li@hotmail.com

Please enter the following 'extra' attributes
A challenge password []:1234
An optional company name []:upl

[root@station245 /]# openssl rsa -in privkey.pem -out station245.cluster.com.key --生成station245.cluster.com.key
Enter pass phrase for privkey.pem:
writing RSA key


[root@station245 /]# openssl x509 -in station245.cluster.com -out station245.cluster.com.crt -req -signkey station245.cluster.com.key -days 365
Signature ok
subject=/C=CN/ST=guangdown/L=shenzhen/O=upl/OU=it/CN=li/emailAddress=li@hotmail.com
Getting Private key

[root@station245 /]# mkdir /etc/httpd/key
[root@station245 /]# cp station245.cluster.com.crt /etc/httpd/key/
[root@station245 /]# cp station245.cluster.com.key /etc/httpd/key/

[root@station245 /]# yum install httpd* -y --安裝rpm版apache
[root@station245 /]# yum install mod_ssl -y --安裝ssl模塊


[root@station245 /]# vim /etc/httpd/conf.d/ssl.conf

SSLCertificateFile /etc/httpd/key/station245.cluster.com.crt
SSLCertificateKeyFile /etc/httpd/key/station245.cluster.com.key


[root@station245 /]# /etc/init.d/httpd restart

[root@station245 /]# netstat -ntlup |grep 443
tcp 0 0 :::443 :::* LISTEN 15662/httpd

使用客戶端訪問:
https://10.1.1.245/ --要用https,並下載證書才可以訪問


====================================


postfix courier-imap maildrop courier-authlib extmail extman spamassassin

postfix postfixadmin dovecot mysql squirrelmail clamAV amavsid-new spamassassin

client
|
|
|
postfix ------------>收件人
|
| 10024 10025
amavsid-new
|
|--------------|
clamav spamassassin


========================================


安裝前準備
主機名
時間同步
關閉iptables ,selinux
yum配置OK


第一大步:
安裝mysql,postfixadmin,httpd


# yum install httpd* mysql* php* -y


# /etc/init.d/mysqld start


安裝postfixadmin (管理postfix的一個web界面的軟體)

# mount 10.1.1.35:/share/soft /mnt
# cp /mnt/postfix postfixadmin/postfixadmin-2.1.0.gz /root/
# tar xvf /root/postfixadmin-2.1.0.gz -C /var/www/html/
--解壓到apache的家目錄,這裡apache是用的rpm版,沒有改家目錄的,所以就是/var/www/html/下
# cd /var/www/html/
# mv postfixadmin-2.1.0/ postfixadmin --改一下名字,便於在web地址欄訪問

# mysql < /var/www/html/postfixadmin/DATABASE_MYSQL.TXT --postfix有一個mysql資料庫的導表的文件,使用這條命令,直接導入資料庫,就會自動創建postfix要使用的一些表


# mysql --再次登錄驗證

mysql> show databases;
--------------------
| Database |
--------------------
| information_schema |
| mysql |
| postfix | --多了一個postfix庫,是剛才導入的
| test |


--------------------

mysql> use postfix; --進入postfix庫


mysql> show tables; --查看庫里的表,下面這些表就是剛才導入的,目前是空表
-------------------
| Tables_in_postfix |
-------------------
| admin |
| alias |
| domain |
| domain_admins |
| log |
| mailbox |
| vacation |


# /etc/init.d/httpd restart

這裡使用瀏覽器http://IP/postfixadmin 訪問postfix的web安裝界面

點setup安裝,會有一個警告和一個錯誤 ,錯誤是提示找不到config.ini.php文件

警告解決方法:
vim /etc/php.ini
magic_quotes_gpc = ON --把這個改為ON


錯誤的解決方法:
# mv /var/www/html/postfixadmin/config.inc.php.sample /var/www/html/postfixadmin/config.inc.php --有一個模版配置文件,重命名


# rm /var/www/html/postfixadmin/setup.php -rf --刪除安裝的信息文件


# /etc/init.d/httpd restart


# vim /var/www/html/postfixadmin/config.inc.php --修改

$CONF['default_language'] = 'cn'; --如果想要中文界面的話,改為cn,當然系統要是中文的

$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO'; --這兩個與後面postfix的mailbox設置有關
--第一個改為YES,表示每一個虛擬域都有自己的郵箱;
--第二個配置為NO表示,不希望域表示在mailbox里


再次訪問http://IP/postfixadmin --用一個中文系統(英文系統如果不想註銷切換,可以 export LANG=zh )中文做客戶端,使用firefox查看會發現有亂碼,這是httpd的語言集不一致造成的


# vim /etc/httpd/conf/httpd.conf

AddDefaultCharset GB2312 --把UTF-8 ,改為GB2312

# /etc/init.d/httpd restart --重啟服務后,再次訪問web界面就OK了

-----------------------

使用下面地址,訪問管理頁面
http://IP/postfixadmin/admin --剛進來,會有新特性等信息,提示刪除motd文件


# rm /var/www/html/postfixadmin/motd* -rf

再訪問管理頁面,就沒有那些信息了

這裡手動添加兩個域,我這裡加了一個aaa.com 和 bbb.com這兩個域

再增加一個管理員, 同時能管理這兩個域,我這裡管理員為admin@aaa.com

修改完成後,這是管理頁面,不對外開放,那麼可以使用系統許可權來對其進行限制

# chmod 000 /var/www/html/postfixadmin/admin/ --把這個目錄許可權改為000,那麼管理頁面就不能再訪問了,如果想再進管理頁面進行信息的修改的話,可以把這個目錄許可權改回755就可以了
--或者使用apache的目錄控制來控制只有管理機可以登錄此頁面,或者使用apache的.htaccess功能把此目錄的訪問許可權設置驗證


===============================
# vim /etc/httpd/conf/httpd.conf

327 AllowOverride all --改為all,表示家目錄下所有目錄都支持.htaccess驗證

--或者加上下面這一段,指定只有admin目錄可以支持.htaccess驗證

AllowOverride all
Order allow,deny
Allow from all

# vim /var/www/html/postfixadmin/admin/.htaccess --默認有此文件

AuthUserFile /var/www/html/postfixadmin/admin/.htpasswd --改這一句
AuthGroupFile /dev/null
AuthName "Postfix Admin"
AuthType Basic


require valid-user

# htpasswd /var/www/html/postfixadmin/admin/.htpasswd admin --修改此文件的admin用戶的密碼
New password:
Re-type new password:
Updating password for user admin

# /etc/init.d/httpd restart


================================================================


第二大步,安裝postfix
這裡我們不使用rpm版的postfix,rpm版默認不支持mysql,所以需要源碼版重新編譯


可以去redhat的ftp網站下載
ftp://ftp.redhat.com

postfix-2.3.3-2.1.el5_2.src.rpm


# useradd -s /sbin/nologin brewbuilder
# rpm -ivh postfix-2.3.3-2.1.el5_2.src.rpm


# cd /usr/src/redhat/SPECS/
# ls
postfix.spec --這是rpm 的src包的配置文件


# vim postfix.spec


[火星人 ] linux23-postfix已經有584次圍觀

http://coctec.com/docs/linux/show-post-45760.html