這篇文章主要介紹“怎么在postfix服務器上配置SASL認證”,在日常操作中,相信很多人在怎么在postfix服務器上配置SASL認證問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么在postfix服務器上配置SASL認證”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
簡介:如果客戶端與postfix沒有處在同一個網絡,則需要通過SASL機制進行認證授權,授權后客戶端就可以與處在同一網絡的客戶端一樣擁有相同的權限了。postfix本身并不實現 SASL,而是采用一個第三方的實現來作為postfix的一個模塊,所以sasl相關的配置有些是屬于postfix,有些屬于第三方模塊。
在postfix服務器上配置SASL認證的步驟:
sasl實現可以提供一系列認證機制,通過配置來選擇使用哪些認證方式。
配置postfix啟用sasl認證并授權客戶端發送郵件或者控制信封上的發件人地址。
postfix通過插件的方式來支持多種不同的sasl實現,比如:Cyrus SASL and Dovecot SASL,可以通過以下命令來查看當前哪些實現編譯進了postfix:
% postconf -a (SASL support in the SMTP server) % postconf -A (SASL support in the SMTP+LMTP client)
配置Dovecot SASL:
1 conf.d/10-master.conf:
2 service auth {
3 ...
4 unix_listener /var/spool/postfix/private/auth {
5 mode = 0660
6 # Assuming the default Postfix user and group
7 user = postfix
8 group = postfix
9 }
10 ...
11 }
12
13 conf.d/10-auth.conf
14 auth_mechanisms = plain login第4行:采用unix-domain socket
第5-8行:配置了只允許postfix用戶和組有讀寫權限
第14行:提供了plain,login兩種認證機制
第一步需要確定配置文件的名稱和位置,配置文件名是postfix smtp服務發送給Cyrus SASL庫的值再加上.conf后綴, postfix發送的值為采用Cyrus SASL的組件名稱,默認為smtpd,所以配置文件名默認為smtpd.conf:
/etc/postfix/main.cf: # Postfix 2.3 and later smtpd_sasl_path = smtpd # Postfix < 2.3 smtpd_sasl_application_name = smtpd
Cyrus SASL會搜尋配置文件的位置,具體需要看Cyrus的版本和一些postfix的發行版本身的規則。
postfix鏈接cyrus sasl 的庫libsasl,通過調用sasl庫來與cyrus通信。sasl庫可以使用外部的密碼校驗服務或者通過內部插件連接到后端的認證服務來認證客戶端:
| authentication backend | password verification service / plugin |
|---|---|
| /etc/shadow | saslauthd |
| PAM | saslauthd |
| IMAP server | saslauthd |
| sasldb | sasldb |
| MySQL, PostgreSQL, SQLite | sql |
| LDAP | ldapdb |
saslauthd:postfix通過unix-domain socket與saslauthd服務進行通信。
在postfix中啟用sasl認證:
postfix默認采用Cyrus sasl實現,可以通過配置改為dovecot:
/etc/postfix/main.cf: smtpd_sasl_type = dovecot
指定dovecot的訪問unix-domain socket地址:
/etc/postfix/main.cf: smtpd_sasl_path = private/auth
如果采用tcp socket通信,可以這樣配置:
/etc/postfix/main.cf: smtpd_sasl_path = inet:127.0.0.1:12345
啟用sasl認證:
/etc/postfix/main.cf: smtpd_sasl_auth_enable = yes
啟用了sasl之后,postfix會在ehlo指令的結果中告訴客戶端不前支持哪些認證機制,但是,有些比較舊的客戶端不能識別這些格式,這時可以配置postfix以兼容格式重復輸出一次以便讓舊的客戶端了能識別:
/etc/postfix/main.cf: broken_sasl_auth_clients = yes
postfix可以配置一些限制策略還允許或禁止某些sasl機制,其選項如下:
| Property | Description |
|---|---|
| noanonymous | Don't use mechanisms that permit anonymous authentication. |
| noplaintext | Don't use mechanisms that transmit unencrypted username and password information. |
| nodictionary | Don't use mechanisms that are vulnerable to dictionary attacks. |
| forward_secrecy | Require forward secrecy between sessions (breaking one session does not break earlier sessions). |
| mutual_auth | Use only mechanisms that authenticate both the client and the server to each other. |
默認的策略配置如下:
/etc/postfix/main.cf: # Specify a list of properties separated by comma or whitespace smtpd_sasl_security_options = noanonymous
注意:至少應該配置禁止匿名認證。
加密TLS會話:
不采用tls會話時,postfix通過另一組參數來配置sasl機制,默認情況下是復制非tls會話的配置:
/etc/postfix/main.cf: smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
如果想分開配置,可以這樣:
/etc/postfix/main.cf: smtpd_sasl_security_options = noanonymous, noplaintext smtpd_sasl_tls_security_options = noanonymous
僅僅在建立了tls會話之后才啟用sasl認證:
/etc/postfix/main.cf: smtpd_tls_auth_only = yes
在客戶端經過認證后,postfix會決定客戶端可以被授權做哪些事情,比如:可以發送郵件給外站用戶,使用特定的信封發件人作為mail from指令值,這些權限默認是不允許的。
郵件轉發授權:
# With Postfix 2.10 and later, the mail relay policy is # preferably specified under smtpd_relay_restrictions. /etc/postfix/main.cf: smtpd_relay_restrictions = permit_mynetworkspermit_sasl_authenticatedreject_unauth_destination
# Older configurations combine relay control and spam control under # smtpd_recipient_restrictions. To use this example with Postfix ≥ # 2.10 specify "smtpd_relay_restrictions=". /etc/postfix/main.cf: smtpd_recipient_restrictions = permit_mynetworkspermit_sasl_authenticatedreject_unauth_destination ...other rules...
到此,關于“怎么在postfix服務器上配置SASL認證”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。