<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - pam</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/pam/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Wed, 01 Apr 2026 16:19:15 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Configure Postfix as standalone single-domain SMTP server using Unix users and PAM on Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2014/02/01/Configure-Postfix-as-STMP-standalone-single-domain-server-using-Unix-users-and-PAM-on-Debian</link>
        <guid isPermaLink="false">urn:md5:e8f08f8049c5bf438f9d352254044c7f</guid>
        <pubDate>Sat, 01 Feb 2014 22:05:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>mail</category>
                  <category>note</category>
                  <category>pam</category>
                  <category>postfix</category>
                  <category>sasl</category>
                  <category>server</category>
                <description>          &lt;p&gt;Here is a quick setup to configure Postfix mail server, using existing Unix users.&lt;/p&gt;

&lt;p&gt;The server will process mails for only one domain, and every existing user on the server will have a mail box inside his home directory.&lt;/p&gt;

&lt;h3&gt;Abstract&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; is an &lt;strong&gt;SMTP&lt;/strong&gt; server, it receives incoming mail from other &lt;strong&gt;SMTP&lt;/strong&gt; servers, and allows client to send mails to other &lt;strong&gt;SMTP&lt;/strong&gt; servers.&lt;/p&gt;

&lt;p&gt;What we don't want is an open mail relay. A mail relay is a &lt;strong&gt;SMTP&lt;/strong&gt; server that take anything from any client, and send it to any &lt;strong&gt;SMTP&lt;/strong&gt; server. We only want trusted users to send emails, to prevent anonymous clients from sending spam.&lt;/p&gt;

&lt;p&gt;Incoming mail will be processed either if :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The domain name of one of the recipient matches the mail server domain, and the mail user name is also a system user (&lt;strong&gt;SMTP&lt;/strong&gt; servers can send us incoming mails).&lt;/li&gt;
	&lt;li&gt;The client who tries to sends the mail has successfully authenticated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; authentication for clients can be handled by &lt;strong&gt;SASL&lt;/strong&gt;. &lt;strong&gt;SASL&lt;/strong&gt; is a standard protocol to provide an authentication layer. It can query &lt;strong&gt;PAM&lt;/strong&gt;, or other authentication providers (MySQL users, etc).&lt;/p&gt;

&lt;p&gt;Notes :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;We will use PAM for Unix users SMTP authentication.&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Unix users are stored in&lt;code&gt; /etc/passwd&lt;/code&gt; and their passwords are stored in &lt;code&gt;/etc/shadow&lt;/code&gt;&lt;/em&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Mails will be stored in the ~/Maildir/ of each users, in Maildir format.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Postfix : installation and configuration&lt;/h3&gt;

&lt;p&gt;Install Postfix : &lt;code&gt;apt-get install postfix&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Answer the questions during installation to setup your mail domain (the &quot;example.com&quot; in user@example.com).&lt;/p&gt;

&lt;p&gt;Modify config files :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Configure TLS and Maildir :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;# TLS parameters&lt;br /&gt;
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key&lt;br /&gt;
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem&lt;br /&gt;
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt&lt;br /&gt;
smtpd_use_tls=yes&lt;br /&gt;
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache&lt;br /&gt;
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache&lt;br /&gt;
&lt;br /&gt;
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for&lt;br /&gt;
# information on enabling SSL in the smtp client.&lt;br /&gt;
&lt;br /&gt;
myhostname = mail.example.com&lt;br /&gt;
alias_maps = hash:/etc/aliases&lt;br /&gt;
alias_database = hash:/etc/aliases&lt;br /&gt;
myorigin = /etc/mailname&lt;br /&gt;
mydestination = example.com, localhost&lt;br /&gt;
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128&lt;br /&gt;
mailbox_size_limit = 0&lt;br /&gt;
recipient_delimiter = +&lt;br /&gt;
&lt;br /&gt;
home_mailbox = Maildir/&lt;br /&gt;
&lt;br /&gt;
# These are the &quot;no relay&quot; restrictions&lt;br /&gt;
smtpd_recipient_restrictions = permit_mynetworks permit_inet_interfaces permit_sasl_authenticated reject_unauth_destination&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/master.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Enable TLS and alternate (submission) ports :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;submission inet n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/submission&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_security_level=encrypt&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;br /&gt;
smtps&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inet&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/smtps&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_wrappermode=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;SASL : installation and configuration&lt;/h3&gt;

&lt;p&gt;SASL plugin for Postfix (Cyrus) is part of the dependencies of Postfix server.&lt;/p&gt;

&lt;p&gt;Install SASL administration tools : &lt;code&gt;apt-get install sasl2-bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enable SASL daemon at startup : edit &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; and switch &lt;code&gt;START&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Start it manually for the first time : &lt;code&gt;service saslauthd start&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Enable PAM authentication for SASL&lt;/h3&gt;

&lt;p&gt;Check that PAM is part of the MECHANISMS variable in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;MECHANISMS=&quot;pam&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/pam.d/smtp&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;#&lt;br /&gt;
# /etc/pam.d/smtp - specify PAM SMTP behavior&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
@include common-auth&lt;br /&gt;
@include common-account&lt;br /&gt;
@include common-password&lt;br /&gt;
@include common-session&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Enable SASL for Postfix&lt;/h3&gt;

&lt;p&gt;Add to &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;smtpd_sasl_auth_enable = yes&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/postfix/sasl/smtpd.conf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;pwcheck_method: saslauthd&lt;br /&gt;
mech_list: PLAIN LOGIN&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adjust &lt;code&gt;OPTIONS&lt;/code&gt; in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;OPTIONS=&quot;-c -m /var/spool/postfix/var/run/saslauthd&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Add &lt;strong&gt;postfix user&lt;/strong&gt; to &lt;strong&gt;sasl group&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;adduser postfix sasl&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Configuration check&lt;/h3&gt;

&lt;p&gt;Restart all services (postfix, salsauthd).&lt;/p&gt;

&lt;p&gt;Try authentication using SASL : &lt;code&gt;testsaslauthd -u user -p password&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Try authentication from command line, without mail client : &lt;a href=&quot;https://qmail.jms1.net/test-auth.shtml&quot; hreflang=&quot;en&quot;&gt;https://qmail.jms1.net/test-auth.shtml&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try SMTP reception by sending mail to your domain (your MX fields in domain has to be configured accordingly).&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#saslauthd&quot; hreflang=&quot;en&quot;&gt;Postfix SASL Howto&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#testing_saslauthd&quot; hreflang=&quot;en&quot;&gt;Testing SASL auth&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://blog.ntrippy.net/2008/05/warning-sasl-authentication-failure.html&quot; hreflang=&quot;en&quot;&gt;Fixing SASL authentication failure: cannot connect to saslauthd server: No such file or directory&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.faqforge.com/linux/how-to-enable-port-587-submission-in-postfix/&quot; hreflang=&quot;en&quot;&gt;How to enable submission ports in Postfix&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.howtoforge.com/community/threads/cannot-connect-to-saslauthd-server-permission-denied.22730/&quot; hreflang=&quot;en&quot;&gt;Cannot connect to saslauthd : permission denied&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
      </channel>
</rss>
