标签:本地邮件 远程邮件 空壳邮件 nmap apache帮助手册 端口
vim/etc/postfix/access
172.25.254.130 REJECT
查看使用参数
postconf -d |grep client
将参数写入文件
postconf -e "smtpd_client_restrictions=check_client_access hash:/etc/postfix/access"
之后vim/etc/postfix/main.cf会发现最后一行出现了
smtpd_client_restrictions =check_client_access hash:/etc/postfix/access
五颜六色哒~~美美哒~
systemctl restart postfix.service
在172.25.254.10 执行 telnet 172.25.254.130 25
可以登陆,但不能使用(发邮件)。
vim/etc/postfix/recip
xixi@lalala.com REJECT
postmap recip加密成db文件
postconf -e"smtpd_sender_restrictions =check_sender_access hash:/etc/postfix/recip"
systemctl restart postfix.service
其他用户可以发邮件,xixi不能。
vim/etc/postfix/recip
xixi@lalala.com REJECT
postmap recip
postconf -e"smtpd_recipient_restrictions = check_recipient_accesshash:/etc/postfix/recip"
systemctl restart postfix.service
其他用户可以收邮件,xixi不能。
cat /etc/services |grep imap 可以查看imap的端口号
vim/etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp dovecot使用的协议
49 disable_plaintext_auth = no 使用明文认证
50 login_trusted_networks = 0.0.0.0/0 使外网也可以使用dovecot服务
vim/etc/dovecot/conf.d/10-mail.conf
30 mail_location =mbox:~/mail:INBOX=/var/mail/%u
netstat -antlupe |grep dovecot
passwd westos
telnet 172.25.254.11 110
user mooc
pass 1
如果登录失败,可以在服务器查看日志(cat /var/log/maillog),获取错误信息
根据提示:mkdir –p /home/mooc/mail/.imap
touch /home/mooc/mail/.imap/INBOX
1)本地
yum install mutt -y
mutt -f imap://westos@172.25.254.11 110
登录成功~~~~
2)雷鸟
由于每个新用户都要手动创建/home/mooc/mail/.imap/INBOX,太麻烦~
所以直接在/etc/skel中创建mail/.imap/INBOX,这样系统在创建新用户时,会自行创建/home/newuser/mail/.imap/INBOX
建立一个虚拟用户(vmail)来管理邮箱数据库,不直接用root,因为风险太大!
groupadd -g 666
useradd -g 666 -u 666 -s /sbin/nologinvmail
1)在数据库中添加信息
2)检测数据库是否读取成功
vim/etc/postfix/mysql-users.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = username
where_field = username
cp-p mysql-users.cf mysql-domain.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = domain
where_field = domain
cp-p mysql-users.cf mysql-maildir.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = maildir
where_field = username
让我们来小小检测一下~~
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-users.cf
postmap -q "westos.org"mysql:/etc/postfix/mysql-domain.cf
postmap -q "admin@westos.org"mysql:/etc/postfix/mysql-maildir.cf
3)将数据写入配置文件
postconf -e "virtual_uid_maps =static:666"
postconf -e "virtual_gid_maps =static:666"
postconf -e "virtual_mailbox_base=/home/vmail" 指定邮箱位置
postconf -e"virtual_alias_maps=mysql:/etc/postfix/mysql-users.cf" 本地文件连接数据库
postconf -e"virtual_mailbox_domains=mysql:/etc/postfix/mysql-domain.cf"
postconf -e"virtual_mailbox_maps=mysql:/etc/postfix/mysql-maildir.cf"
最后配置文件变成:
mailadmin@westos.org
即本地没有org这个域名,在org在数据库中,实现org用户之间的相互通信
yum install dovecot-mysql -y
vim/etc/dovecot/conf.d/auth-sql.conf.ext 查看模板位置
cp -p /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot
vim /etc/dovecot/dovecot-sql.conf.ext
32driver = mysql 驱动
70connect = host=localhost dbname=email user=postfix password=postfix
使用本地用户(postfix)连接数据库email,他通常只拥有select权限(在企业中)
77default_pass_scheme = PLAIN 登陆密码明文(数据库)
106 password_query = \
107 SELECT username, domain, password \
108 FROM muser WHERE username = ‘%u‘ AND domain = ‘%d‘
%u=entire user@domain
%d=domainpart of user@domian
%n=userpart in user@domian,same as %u if there is no domain
124 user_query = SELECT maildir, 666 AS uid,666 AS gid FROM muser WHERE username = ‘%u‘
vim10-mail.conf
30 mail_location =maildir:/home/vmail/%d/%n 邮箱的位置
168 first_valid_uid = 666 使虚拟用户和mail有联系
175 first_valid_gid = 666
vim10-auth.conf
122 !include auth-system.conf.ext系统用户
123 !include auth-sql.conf.ext 数据库用户
首先检测mooc 是否能通过172.25.254.11的110端口登录,登录成功才说明配置成功,才有可能使用雷鸟~
在雷鸟上可以实现admin@westos.org和zoe@westos.org互发邮件!!!
1)/run/dovecot 对于mooc没有w权限
解决方法: chmod o+w /run/dovecot
2)dovecot不能识别mysql
解决方法:yum install dovecot-mysql –y
邮件服务器是mat,通常运行smtp协议(发邮件的时候),比较重要,不能暴露在外面,所以要找个傀儡。
表面上,邮件都发给傀儡,实际上邮件全部发给服务器,傀儡那里一点数据都没有~
空壳(傀儡):10
vim/etc/resolv.conf
nameserver 172.25.254.10
vim/etc/named.rfc1912.zones
zone "westos.org" IN {
type master;
file "westos.org.zone";
allow-update { none; };
};
vimwestos.org.zone
dns A 172.25.254.10
westos.org. MX 1 172.25.254.10.
vim/etc/postfix/main.cf
75 myhostname = mailwestos.westos.com 真实主机信息
83 mydomain = westos.com 真实主机信息
98 myorigin = westos.org 我要接受哪个域的邮件
113 inet_interfaces = all
140 local_transport = error:local deliverydisabled
提示用户我是一个空壳,不要给我发邮件了!!!
164 mydestination = 我就不接受邮件,你们傻了吧
313 relayhost = 172.25.254.230 把邮件传递给我的真实服务器
别忘了关火墙!
服务器
vim /etc/postfix/main.cf
264 mynetworks = 172.25.254.10 我的傀儡的ip
空壳端:mail admin@westos.org 给自己发邮件,邮件并不在自己的收件箱。
服务器:rm -rf /home/vmail/*
会发现在产生/home/vmail/westos.org/admin 的目录,并且邮件在new/下
1.httpd
httpd 是有http协议的软件
2.架构
lamp=linux apache mysql php
lump=linux nginx mysql php
nginx 共享
jsp asp 动态,用tomcat jbosss 翻译读不懂的语言
squied 代理软件
3.server
curl -I www.taobao.com
server 访问淘宝时访问的淘宝的哪一个服务(软件)
4.nmap
nmap我的虚拟机,查看哪个端口开着
nmap 度~娘 (侵删)
apache默认访问端口80
tomcat 8080
vim /etc/httpd/conf/httpd.conf
/Listen
42 Listen 8080
apache 默认访问/var/www/html/index.html
1)更改apache默认发布主页
vim /etc/httpd/conf/httpd.conf
/index
170 <IfModule dir_module>
171 DirectoryIndex file index.html
172 </IfModule>
哪个文件在前面先访问哪个,如果为空,将访问apache官方主页
2)访问apache帮助手册
yum install http-manual -y
在浏览器访问http://172.25.254.230/manual
3)更改默认访问目录
vim /etc/httpd/conf/httpd.conf
/DocumentRoot
120 DocumentRoot "/www/westos"
121
122 <Directory "/www/westos"> 目录的授权
123 Require all granted
124 </Directory>
在getenforce=Enforcing 时,如果上下文标签不一致时,将不能通过apache访问
所以要将新目录的上下文标签改成http_sys_content_t:s0
mkdir /www/westos -p
semanage fcontext -a -t httpd_sys_content_t‘/www/westos(/.*)?‘
restorecon -RccF /www/
vim index.html
/www/westos
lalallaa
systemctl reload httpd 同 kill 1
结果图:
4)访问控制
1)通过ip控制
120 DocumentRoot "/www/westos"
121
122 <Directory "/www/westos">
123 Require all granted
124 Order Allow,Deny
125 Allow from 172.25.254.88
126 Deny from ALL 所有人都不能访问
127 </Directory>
124 Order Deny,Allow
125 Allow from 172.25.254.88 172.25.254.10 只有88,10能访问
126 Deny from ALL
124 Order Deny,Allow
125 Allow from 172.25.254.0/24 所有网段都能访问
126 Deny from ALL
124 Order Deny,Allow
125 Allow from 172.25.254.88 只有88能访问
126 Deny from ALL
结论:以最后读取的allow或deny为准
2)通过密码控制
cd /etc/httpd/
htpasswd -cm htpasswdfile admin 第一次创建用户 -c create
htpasswd -m htpasswdfile westos 之后创建用户
-m Force MD5 encryption of the password (default).
122 <Directory "/www/westos">
123 AllowOverride All
124 Authuserfile/etc/httpd/htpasswdfile
125 Authname "Please inputusername and password"
126 Authtype basic
127 Require valid-user /etc/httpd/htpasswdfile里的用户
Requireadmin 只允许admin。
128 </Directory>
admin 正确输入用户名和密码,进去啦~
但在当前配置下,Require admin,zoe不能进去。
配置为Require valid-user
/etc/httpd/htpasswdfile里所有的用户,才能都进入。
清除缓存Ctrl+Shift+Delete
apache 虚拟主机
vim /etc/hosts
172.25.254.230 www.westos.com westos.com news.westos.commusic.westos.com
建立子服务器目录
mkdir/var/www/virtual/news.westos.com/html -p
mkdir/var/www/virtual/music.westos.com/html -p
写子服务器主页
vim var/www/html/index.html
default
vim /var/www/virtual/music.westos.com/html/index.html
music
vim/var/www/virtual/news.westos.com/html/index.html
news
为什么要把news.conf,music.conf,default.conf写在/etc/httpd/conf.d下?
vim /etc/httpd/conf/httpd.conf
356 IncludeOptional conf.d/*.conf
可以看到apache默认读取/etc/httpd/conf.d/下以conf结尾的文件
cd /etc/httpd/conf.d
1.vim news.conf
<Virtualhost *:80>
Servername news.westos.com
Documentroot /var/www/virtual/news.westos.com/html
Customlog "logs/news.log" combined
</Virtualhost>
<Directory"/var/www/virtual/news.westos.com/html">
Require all granted
</Directory>
2.vim music.conf
<Virtualhost *:80>
Servername music.westos.com
Documentroot /var/www/virtual/music.westos.com/html
Customlog "logs/music.log" combined
</Virtualhost>
<Directory"/var/www/virtual/music.westos.com/html">
Require all granted
</Directory>
3.vim default.conf
<Virtualhost _default_:80>
Documentroot /var/www/html
Customlog "logs/default.log" combined
</Virtualhost>
<Directory "/var/www/html">
Require all granted
</Directory
vim /etc/hosts
服务器解密,客户端加密
yum install mod_ssl -y
会生成这个文件:/etc/httpd/conf.d/ssl.conf
systemctl restart httpd
netstat -antlpe |grep httpd
使用https://www.westos.com 会因为缺少证书,无法访问
安装生成证书的软件
yuminstall crypto-utils -y
加密公司网址
genkeywww.westos.com
/etc/pki/tls/certs/www.westos.com.crt
/etc/pki/tls/private/www.westos.com.key
vim/etc/httpd/conf.d/ssl.conf
100 SSLCertificateFile/etc/pki/tls/certs/www.westos.com.crt
107 SSLCertificateKeyFile/etc/pki/tls/private/www.westos.com.key
systemctl restart httpd
我的证书~~~~~
本文出自 “12049878” 博客,谢绝转载!
标签:本地邮件 远程邮件 空壳邮件 nmap apache帮助手册 端口
原文地址:http://12059878.blog.51cto.com/12049878/1879702