Postfix别名邮件与SASL验证

环境简介

系统:

  • CentOS 8.3.2011

软件包:

  • postfix-2:3.3.1-12.el8.x86_64
  • cyrus-sasl-2.1.27-5.el8.x86_64
  • cyrus-sasl-plain-2.1.27-5.el8.x86_64

软件源:

  • CentOS-8.3.2011-x86_64-dvd1.iso 自带软件源

操作步骤

如下为Postfix配置SASL验证。

[root@localhost ~]# yum install -y vim postfix cyrus-sasl net-tools
# 最小化安装系统 安装所需软件包 Yum配置略过
[root@localhost ~]# vim /etc/postfix/master.cf
# 修改Postfix配置文件,将以下项的注释删除 开启smtpd功能,修改完成后保存退出
smtpd pass - - n - - smtpd
[root@localhost ~]# vim /etc/postfix/main.cf
# 修改Postfix配置文件,完成初始化配置及开启SASL验证功能。如下项最好根据实际情况修改。
myhostname = mail.studying.com
mydomain = studying.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks_style = subnet
mynetworks = 192.168.100.0/24, 127.0.0.0/8
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes [root@localhost ~]# systemctl enable --now postfix
# 启动Postfix并设置Postfix开机自启
[root@localhost ~]# firewall-cmd --add-service=smtp --per
[root@localhost ~]# firewall-cmd --reload
# 设置防火墙允许访问smtp服务

配置SASL2

[root@localhost ~]# setsebool -P allow_saslauthd_read_shadow 1
# 设置SELinux允许saslauthd访问/etc/shadow文件
[root@localhost ~]# cat /etc/sasl2/smtpd.conf
# 文件默认内容应该就如下所示
pwcheck_method: saslauthd
mech_list: plain login [root@localhost ~]# vim /etc/sysconfig/saslauthd
# 修改saslauthd的配置文件
MECH=shadow [root@localhost ~]# systemctl enable --now saslauthd
# 开启并开机自启sasl验证服务
testsaslauthd -u testuser1 -p abc.123
0: OK "Success."
# 测试sasl验证是否正常

接下来为Postfix配置别名。

[root@localhost ~]# postconf -p | grep alias_maps
alias_maps = hash:/etc/aliases
# 检查别名文件,并在文件中添加如下内容
[root@localhost ~]# vim /etc/aliases
testuser: testuser1, testuser2, testuser3
[root@localhost ~]# newaliases
# 使用如上命令重新生成别名数据库
[root@localhost ~]# systemctl restart postfix
# 重启Postfix服务

测试环境

接下来使用telnet命令行进行测试

# 如下命令使用命令行进行测试
220 mail.studying.com ESMTP Postfix
helo testuser1@studying.com
250 mail.studying.com
auth login
334 VXNlcm5hbWU6
dGVzdHVzZXIx
334 UGFzc3dvcmQ6
YWJjLjEyMw==
235 2.7.0 Authentication successful
mail from:<testuser1@studying.com>
250 2.1.0 Ok
rcpt to:<testuser1@studying.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
This is a test mail
.
250 2.0.0 Ok: queued as A895C2088490
mail from:<testuser1@studying.com>
250 2.1.0 Ok
rcpt to:<testuser@studying.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
this is a testmail two!
.
250 2.0.0 Ok: queued as 9AA66208849A # 邮件发送完毕后通过在用户家目录查阅邮件,从而验证邮件发送的成功
[root@localhost new]# pwd
/home/testuser1/Maildir/new [root@localhost new]# cat 1661604766.Vfd00I20e7d75M249613.localhost.localdomain
Return-Path: <testuser1@studying.com>
X-Original-To: testuser1@studying.com
Delivered-To: testuser1@studying.com
Received: from testuser1?studying.com (unknown [192.168.100.1])
by mail.studying.com (Postfix) with SMTP id A895C2088490
for <testuser1@studying.com>; Sat, 27 Aug 2022 20:52:27 +0800 (CST) This is a test mail [root@localhost new]# pwd
/home/testuser2/Maildir/new [root@localhost new]# cat 1661618666.Vfd00I20e7d7dM301979.localhost.localdomain
Return-Path: <testuser1@studying.com>
X-Original-To: testuser@studying.com
Delivered-To: testuser@studying.com
Received: from testuser1?studying.com (unknown [192.168.100.1])
by mail.studying.com (Postfix) with SMTP id 9AA66208849A
for <testuser@studying.com>; Sun, 28 Aug 2022 00:44:10 +0800 (CST) this is a testmail two!

SASL杂谈

SASL(Simple Authentication and Security Layer)简单身份验证和安全层,是由IETF开发的协议,用于提供可插入或可扩展的身份验证框架,具体的定义参见RFC4422。这个协议通常用于电子邮件相关的协议,例如SMTP、IMAP、POP还有XMPP、LDAP等,在上述与Postfix相结合的实例中,我们只是使用到了它的简单身份验证,并没有用到安全层。

关于安全层的内容暂且按下不谈,先聊聊SASL在整个身份验证架构中的位置。首先,SASL是处于服务协议(例如SMTP、IMAP)与验证机制(Plain、GSSAPI)之间的机制,那么一旦配置了SASL的认证,它往往能够隐藏验证机制,但不会隐藏验证机制的细节,例如不同的机制需要不同的信息进行验证,例如一些机制需要使用Kerberos的票据、证书等。

在SASL的验证架构中,涉及到的有两种身份:

  • 与认证凭据相关的身份(称为身份验证身份)
  • 充当的身份(授权身份)

在服务器进行验证的过程中,需要建立身份验证的身份与授权的身份的一一映射,也就是验证账户到实际账户的映射(而这个形式则是由应用程序所规定的)。

那么我们回到上述的POSTFIX+SASL实例中,POSTFIX实质是通过Unix进程间通信来传递身份凭据进行验证。并且采用的验证方法是访问/etc/shadow文件来确定验证结果。

Postfix别名邮件与SASL验证的更多相关文章

  1. CentOS利用postfix搭建邮件服务器

    之前我用nodemailer通过163邮箱来发送邮件,不过没过几天就一直ETIMEDOUT,不知道什么原因,想着还是自己搭一个来发邮件可能靠谱点(flag?) 安装postfix CentOS 7 自 ...

  2. centos6.8 搭建postfix/dovecot邮件服务器

    postfix/dovecot邮件服务器 安装配置参考链接  http://www.cnblogs.com/jkklearn/p/7280045.html (domain 为自己域名 xxx.com) ...

  3. 工程师技术(二):postfix基础邮件服务、postfix空客户端邮件服务、搭建mariadb数据库系统、配置一个数据库、使用数据库查询

    一.postfix基础邮件服务 目标: 本例要求在虚拟机server0上配置 postfix 基础服务,具体要求如下: 1> 监听本机的所有接口    2> 将邮件域和邮件服务主机名都改为 ...

  4. memcached SASL验证状态安全绕过漏洞

    漏洞版本: memcached 1.x 漏洞描述: Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载. Memcached在处理链接的SASL验证状态时存在错 ...

  5. postfix 设置邮件头翻译,本域邮件不进行邮件头翻译,仅发送至外网的进行邮件头翻译?

    postfix 设置邮件头翻译,本域邮件不进行邮件头翻译,仅发送至外网的进行邮件头翻译? 现在设置的 smtp_generic_maps = hash:/etc/postfix/generic sen ...

  6. Linux中用postfix搭建邮件服务器实战详解

    Linux中用postfix搭建邮件服务器实战详解 postfix是Wietse Venema在IBM的GPL协议之下开发的MTA(邮件传输代理)软件.Postfix试图更快.更容易管理.更安全,同时 ...

  7. postfix基础邮件服务

                                                              postfix基础邮件服务  案例1:postfix基础邮件服务 1.1 问题 本例 ...

  8. CentOS 使用PostFix搭建邮件服务器

    搭建环境: 关于PostFix是什么以及邮件服务器接受发送邮件流程网上有很多文章,这里就不再写了,这里只记录如何搭建邮件服务器,使用PostFix接受发送邮件 CentOS6.8 32位,postfi ...

  9. 转-阿里云CentOS Linux服务器上用postfix搭建邮件服务器

    http://www.cnblogs.com/dudu/archive/2012/12/12/linux-postfix-mailserver.html 注:本文的邮件服务器只用于发送邮件,也就是ST ...

随机推荐

  1. CentOS8设置国内镜像源(阿里云镜像)

    CentOS8设置国内镜像源(阿里云) 1.备份原有配置 [root@localhost ~]# mkdir /etc/yum.repos.d.bak [root@localhost ~]# mv / ...

  2. ngx_http_fastcgi_module 的那些事

    是什么? 顾名思义,是Nginx用来处理FastCGI的模块.FastCGI是什么?这个以后再讲,可以说的是现在LNMP架构里面,PHP一般是以PHP-CGI的形式在运行,它就是一种FastCGI,我 ...

  3. Gitee整改之思考

    本文主要内容如下: 1.Gitee是什么? 2.Gitee与Github的区别有哪些? 3.为什么要使用Gitee? 4.Gitee的商业模式是怎样的? 5.Gitee为何会被整改? 6.Gitee这 ...

  4. PHP时间轴函数

    PHP时间轴函数可以更好的去进行用户体验.让用户动态的知道最近是什么时候,而不是死板的datatime去转换成固定的时间. 后续版本会考虑添加这个功能,代码先贴出来. function tranTim ...

  5. sql-扩展sql

    复制表结构 create table 表名 like 被复制的表名; -- 仅复制表表结构 oracle不支持 复制表结构和数据(子查询方式) CREATE TABLE 表名 [AS] SELECT ...

  6. 利用laravel-echo主动向服务端发送消息,实现在线状态管理

    之前在网上翻了半天,也没有找到关于如何 通过laravel-echo主动发送消息 和 在laravel-websockets中自定义控制器 的文章或教程.无奈之下只能翻laravel-echo和lar ...

  7. 一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]

    ASP.NET Core应用本质上就是一个由中间件构成的管道,承载系统将应用承载于一个托管进程中运行起来,其核心任务就是将这个管道构建起来.在ASP.NET Core的发展历史上先后出现了三种应用承载 ...

  8. JDK的下载与安装和环境变量的配置

    一.jdk下载打开浏览器在地址栏输入: http://www.oracle.com ,进入Oracle官网主页面,选择 Products-----Java---->Download Java . ...

  9. centos更改mac

    centos 6更改mac vim /etc/udev/rules.d/70-persistent-net.rules

  10. Codeforces Round #796 (Div. 2)(A~E题题解)

    文章目录 原题链接: A.Cirno's Perfect Bitmasks Classroom 思路 代码 B.Patchouli's Magical Talisman 思路 代码 C.Manipul ...