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. Ubuntu远程桌面助手(URDC)

    目前自动驾驶域控制器项目中使用了英伟达的Orin芯片+Ubuntu20.04系统.域控属于典型的Headless设备,开发调试时需要连接显示器(HDMI/DP).鼠标和键盘,或者使用NoMachine ...

  2. RocketMQ事务消息机制

    1.half消息对消费者不可见,用于确定MQ服务正常. 2.MQ响应half消息. 3.生产者执行本地事务. 4.生产者发送具体消息+本地事务状态,MQ根据本地事务状态执行Commit或者Rollba ...

  3. bat-使用bat安装jdk和配置环境变量

    文件路径 @echo off Setlocal enabledelayedexpansion @REM vscode中自动开启延迟环境变量扩展, %~d0 cd %~dp0 @REM dir echo ...

  4. [BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入

    记录一下BUUCTF中两个类似的SSTI注入关卡 [BJDCTF2020]The mystery of ip-1: 1.打开之后显示如下: 2.在hint.php中进行了相关提示,如下: 3.既然获取 ...

  5. 《Ranked List Loss for Deep Metric Learning》CVPR 2019

    Motivation: 深度度量学习的目标是学习一个嵌入空间来从数据点中捕捉语义信息.现有的成对或者三元组方法随着模型迭代过程会出现大量的平凡组导致收敛缓慢.针对这个问题,一些基于排序结构的损失取得了 ...

  6. labview从入门到出家1--第一个加法程序

    概述: Labview在众多编程语言中排名靠后,显然在当今互联网,物联网时代并非主流语言.但是俗话说行行 出状元,即便不是立身于某个主流的领域,用好了依旧可以独领风骚,而且Labview对于硬件出身的 ...

  7. java,接口

    package Demo.oop.APP.Demo07; //interface 定义接口的关键字:接口都需要实现类 public interface UserService { //接口中的所有的定 ...

  8. jdbc 09: preparedStatement实现增删改查

    jdbc连接mysql,利用preparedStatement实现增删改查 package com.examples.jdbc.o9_preparedStatement实现增删改; import ja ...

  9. day02-2

    JAVA入门 1.C&&C++ 1972年C诞生 贴近硬件,运行极快,效率极高 操作系统,编译器,数据库,网络系统等 指针和内存管理 1982年C++诞生 面向对象 兼容C 图形领域. ...

  10. 请问为啥计算器16进制FFFFFFFFFFFF时10进制是-1?

    请问为啥计算器16进制FFFFFFFFFFFF时10进制是-1?