4
4
Password scheme means the format in which the password is stored in <password
5
databases> [PasswordDatabase.txt]. The most commonly used password schemes are:
7
* *PLAIN*: Password is in plaintext.
8
* *CRYPT*: Traditional DES-crypted password in '/etc/passwd' (e.g. "pass" =
10
* Dovecot uses libc's 'crypt()' function, which means that CRYPT is usually
11
able to recognize MD5-CRYPT and possibly also other password schemes.
12
Please see the notes below regarding glibc's 'crypt()' and SHA-256/512
14
* The traditional DES-crypt scheme only uses the first 8 characters of the
15
password, the rest are ignored. Other schemes may have other password
16
length limitations (if they limit the password length at all).
17
* *MD5-CRYPT*: MD5 based salted password hash nowadays commonly used in
18
'/etc/shadow'. (e.g. "pass" = '$1$ozdpg0V0$0fb643pVsPtHVPX8mCZYW/')
19
* *MD5*: Alias for MD5-CRYPT. Dovecot versions earlier than v1.0.rc16 need
20
to use this instead of MD5-CRYPT. This name is deprecated because
21
MD5-CRYPT isn't an actual MD5 hash.
22
* *PLAIN-MD5*: An actual MD5 hash of the password. (e.g. "pass" =
23
'1a1dc91c907325c69271ddf0c944bc72')
5
databases> [PasswordDatabase.txt]. The main reason for choosing a scheme other
6
than *PLAIN* is to prevent someone with access to the password database (such
7
as a hacker) from stealing users' passwords and using them to access other
13
You should choose the strongest crypt scheme that's supported by your system.
14
From strongest to weakest:
16
* *BLF-CRYPT*: This is the Blowfish crypt (bcrypt) scheme. It is generally
17
considered to be very secure. The encrypted password will start with '$2a$'
18
(Note: bcrypt is not available on most Linux distributions)
19
* *SHA512-CRYPT*: A strong scheme. The encrypted password will start with
21
* *SHA256-CRYPT*: A strong scheme. The encrypted password will start with
23
* *MD5-CRYPT*: A weak but common scheme often used in '/etc/shadow'. The
24
encrypted password will start with '$1$'
26
Note that the above schemes are implemented by the libc's 'crypt()' function.
27
Using them is especially useful when sharing the same passwords with other
28
software, because most of them support using 'crypt()' to verify the password.
29
However, not all libcs (especially older ones) implement all of the above
30
schemes. See below for other password schemes that are implemented by Dovecot
31
internally (instead of libc).
33
A few articles about why choosing a good password scheme is important:
35
* How To Safely Store A Password
36
[http://codahale.com/how-to-safely-store-a-password/]
37
* Speed Hashing [http://www.codinghorror.com/blog/2012/04/speed-hashing.html]
39
It's not possible to easily switch from one password scheme to another. The
40
only practical way to do this is to wait until user logs in and change the
41
password during the login. <This HOWTO> [HowTo.ConvertPasswordSchemes.txt]
42
shows one way to do this.
44
Generating encrypted passwords
45
------------------------------
47
You can generate passwords for a particular scheme easily with "doveadm pw"
50
---%<-------------------------------------------------------------------------
51
doveadm pw -s SHA512-CRYPT
52
---%<-------------------------------------------------------------------------
54
Default password schemes
55
------------------------
25
57
Password databases have a default password scheme:
41
73
The password scheme can be overridden for each password by prefixing it with
42
74
{SCHEME}, for example:'{PLAIN}pass'.
44
You can generate passwords for wanted scheme easily with "doveadm pw" utility.
47
---%<-------------------------------------------------------------------------
49
---%<-------------------------------------------------------------------------
51
It's not possible to easily switch from one password scheme to another. The
52
only practical way to do this is to wait until user logs in and change the
53
password during the login. <This HOWTO> [HowTo.ConvertPasswordSchemes.txt]
54
shows one way to do this.
59
With most installations it doesn't really matter what scheme you're using. If
60
you already have users with existing passwords, it's easiest to just keep using
61
the same scheme. Otherwise just pick something strong enough, for example
64
The main idea behind storing passwords in non-plaintext scheme is that if an
65
attacker gets access to your server, he can't easily just get all users'
66
passwords and start using them. With stronger schemes it takes more time to
69
76
Non-plaintext authentication mechanisms
70
77
---------------------------------------
76
83
The problem with non-plaintext auth mechanisms is that the password must be
77
84
stored either in plaintext, or using a mechanism-specific scheme that's
78
incompatible with all other non-plaintext mechanisms. For example if you're
79
going to use CRAM-MD5 authentication, the password needs to be stored in either
80
PLAIN or CRAM-MD5 scheme. If you want to allow both CRAM-MD5 and DIGEST-MD5,
81
the password must be stored in plaintext.
85
incompatible with all other non-plaintext mechanisms. In addition, the
86
mechanism-specific schemes often offer very little protection. This isn't a
87
limitation of Dovecot, it's a requirement for the algorithms to even work.
89
For example if you're going to use CRAM-MD5 authentication, the password needs
90
to be stored in either PLAIN or CRAM-MD5 scheme. If you want to allow both
91
CRAM-MD5 and DIGEST-MD5, the password must be stored in plaintext.
83
93
In future it's possible that Dovecot could support multiple passwords in
84
94
different schemes for a single user.
89
*PLAIN*, *CRYPT* and *MD5-CRYPT* schemes were explained above.
91
Non-plaintext mechanism specific schemes:
93
96
* *LANMAN*: DES-based encryption. Used sometimes with NTLM mechanism.
94
97
* *NTLM*: MD4 sum of the password stored in hex. Used with NTLM mechanism.
95
98
* *RPA*: Used with RPA mechanism.
97
100
* *DIGEST-MD5*: Used with <DIGEST-MD5 mechanism>
98
101
[Authentication.Mechanisms.DigestMD5.txt]. The username is included in the
99
102
hash, so it's not possible to use the hash for different usernames.
103
* *SCRAM-SHA-1*: Used with SCRAM-SHA-1 mechanism. (v2.2+)
105
Other supported password schemes
106
--------------------------------
108
Strong schemes and mechanism-specific schemes are listed above.
110
* *PLAIN*: Password is in plaintext.
111
* *CRYPT*: Traditional DES-crypted password in '/etc/passwd' (e.g. "pass" =
113
* Dovecot uses libc's 'crypt()' function, which means that CRYPT is usually
114
able to recognize MD5-CRYPT and possibly also other password schemes. See
115
all of the *-CRYPT schemes at the top of this page.
116
* The traditional DES-crypt scheme only uses the first 8 characters of the
117
password, the rest are ignored. Other schemes may have other password
118
length limitations (if they limit the password length at all).
101
120
MD5 based schemes:
119
138
password hash is base64 or hex encoded, so both can be used.'doveadm pw' anyway
120
139
generates the passwords using the encoding mentioned above.
122
SHA256 and SHA512 in libc
123
-------------------------
125
glibc v2.7+ supports SHA256 and SHA512 based password schemes. The passwords
128
* SHA256: $5$salt$data
129
* SHA512: $6$salt$data
131
These passwords are completely different than what Dovecot generates. They use
132
multiple rounds of SHA, so they're also safer against brute forcing (but also
133
requiring more CPU from your server). You can use these simply by using CRYPT
134
scheme, assuming your libc can handle these kinds of passwords.
136
One way to generate this type of password hash is via the mkpasswd command
137
included in the whois package. For example:'mkpasswd -m sha-512'
139
This is especially useful for sharing the same password file with other
140
software. It can be used with Apache's basic authentication in lieu of the much
141
less secure htpasswd as the check is passed through to the system's crypt(3)