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. 物联网lora无线数传模块应用案例:LoRawan网关通信技术

    什么是LoRa LoRa(Long Range) 无线通信技术是 Semtech 在2012年开发出来的一款适合物联网使用的射频IC.其设计理念为低功耗.长距离.低成本.网路简单.易于扩展的无线数传技 ...

  2. SpringBoot整合RabbitMQ实战附加死信交换机

    前言 使用springboot,实现以下功能,有两个队列1.2,往里面发送消息,如果处理失败发生异常,可以重试3次,重试3次均失败,那么就将消息发送到死信队列进行统一处理,例如记录数据库.报警等 环境 ...

  3. AsList()方法详解

    AsList()方法详解 在Java中,我们应该如何将一个数组array转换为一个List列表并赋初始值?首先想到的肯定是利用List自带的add()方法,先new一个List对象,再使用add()方 ...

  4. flink-执行模式

    flink的执行模式 flink既能处理离线数据,也能处理实时数据,在1.12.0版本以前,批数据返回的数据集合是dataSet,对应一套dataSet的api,从1.12.0版本以后,flink实现 ...

  5. VisonPro · 视觉定位工具包示例

    一.概述 视觉定位工具包一般包含: 1.相机取像: 2.图像九点标定: 3.Mark点粗定位: 4.建立粗定位坐标系: 5.Mark点精定位 6.输出Mark点坐标,角度等信息. 二.分类 1.单特征 ...

  6. VisionPro · C# · 图像显示十字光标

    程序通过 CogRecordDisplay 显示控件显示视觉运行结果图像,当我们对调试时,可能需要用到图像中心十字对位光标. 本文通过VisionPro两个拟合线工具,一个拟合圆工具在图像中画出光标, ...

  7. vue 项目知识

    Vue使用 Vue 源码解析 Vue SSR 如何调试Vue 源码 如何学习开源框架---> 从它的第一次commit 开始看 国外的文章 大致了解写框架的过程(英文关键字) 找到关键---&g ...

  8. 智能指针思想实践(std::unique_ptr, std::shared_ptr)

    1 smart pointer 思想 ​ 个人认为smart pointer实际上就是一个对原始指针类型的一个封装类,并对外提供了-> 和 * 两种操作,使得其能够表现出原始指针的操作行为. ​ ...

  9. Nginx配置解决NetCore的跨域

    使用Nginx配置解决NetCore的跨域 废话不多说,直接上Nginx配置 server { listen 80; server_name 你的Id或域名; location / { add_hea ...

  10. Scala的基础用法 和 Java相对应学习(二)变量、循环、语法

    一.配置相关环境 1.增加项目 在idea里面创建新的maven项目 2. 在pom文件中增加依赖 <?xml version="1.0" encoding="UT ...