10

I used one web based control panel to create some virtual users for Dovecot. That control panel no longer works so I need to do this manually.

I need to reset the password for one (virtual) user which is listed in dovecot.passwd file. The file uses CRYPT schema. How do I reset that password?

So the question boils down to - what can use to convert plain text password to CRYPT encrypted format?

AppleGrew
  • 407
  • 2
  • 6
  • 14

4 Answers4

20

You can use the doveadm utility that comes with Dovecot:

$ doveadm pw -s CRYPT
Enter new password: 
Retype new password: 
{CRYPT}1cElWVzS3.EVg
Richard Hansen
  • 3,640
  • 1
  • 18
  • 17
7

You can use the Apache utility htpasswd. It uses crypt() to encrypt passwords by default on Linux platforms. The following will prompt you for the new password for the user jscott and will update the file /etc/dovecot/dovecot.passwd.

htpasswd /etc/dovecot/dovecot.passwd jscott

jscott
  • 24,204
  • 8
  • 77
  • 99
  • 2
    Word of caution. If you are using the same file as userdb too then it will have other fields which the above method will remove. So instead I guess the safer way is to use `htpasswd -n jscott`. This will print the encrypted password to console. Copy that manually into the passwd file. – AppleGrew Feb 06 '12 at 03:21
  • If you have CentOS, you might not have htpasswd `yum install httpd-tools` via http://serverfault.com/a/568771/82801 Also, use the `-c` switch to create the file if you don't have `dovecot.passwd` yet. – PJ Brunet Feb 10 '17 at 18:38
5

or to avoid the prompts do:

doveadm pw -s CRYPT -p yourpassword -u user

heyMelo27
  • 57
  • 1
  • 2
  • 9
    This is generally a bad practice however, as the line (including the plain text password) will show in your shell history, running commands, etc. – Andrew White Sep 22 '16 at 23:31
1

doveadm pw -s SHA512-CRYPT

is also good.

eric
  • 11
  • 1