Last active
April 27, 2019 13:58
-
-
Save hurtsky/4fe96fdb63389e184a65119f93384b73 to your computer and use it in GitHub Desktop.
how to get 90% + in email grader or use cram-md5 in vestaCP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this tutorial provided without any guarantee! | |
# only tested in ubuntu 16.04 64bit | |
--- 1st step --- | |
open /usr/local/vesta/bin/v-add-email | |
navigate to 'Action' and change to this | |
# Generating hashed password | |
# salt=$(generate_password "$PW_MATRIX" "8") | |
# md5="{md5}$($BIN/v-generate-password-hash md5 $salt <<<$password)" | |
crammd5="$($BIN/v-generate-password-cram-md5 $password)" | |
# Adding account info into password file | |
if [[ "$MAIL_SYSTEM" =~ exim ]]; then | |
if [ "$quota" = 'unlimited' ]; then | |
quota='0' | |
fi | |
str="$account:$crammd5:$user:mail::$HOMEDIR/$user:$quota" | |
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd | |
fi | |
--- 2nd step --- | |
create new file /usr/local/vesta/bin/v-generate-password-cram-md5 | |
(important! make sure use same permission and group as others file) | |
edit v-generate-password-cram-md5 | |
----------------------------------------------------------------- | |
#!/usr/local/vesta/php/bin/php | |
<?php | |
//# info: generate cram-md5 | |
//# options: PASSWORD | |
// | |
//# The function generates password hash | |
// Checking arguments | |
if (empty($argv[1])) { | |
echo "Error: not enought arguments\n"; | |
echo "Usage: " . $argv[0] ." PLAIN_PASSWORD \n"; | |
exit(1); | |
} | |
$password = $argv[1]; | |
$hash = rtrim(shell_exec(escapeshellcmd("/usr/bin/doveadm pw -s CRAM-MD5 -p $password"))); | |
// Printing result | |
echo $hash . "\n"; | |
----------------------------------------------------------------- | |
--- 3th step --- | |
open /etc/dovecot/conf.d/10-auth.conf | |
edit to this | |
---- | |
disable_plaintext_auth = yes | |
auth_verbose = yes | |
auth_mechanisms = cram-md5 | |
---- | |
--- 4th step --- | |
open /etc/dovecot/conf.d/auth-passwdfile.conf.ext | |
edit to this | |
---- | |
passdb { | |
driver = passwd-file | |
args = scheme=cram-md5 username_format=%n /etc/exim4/domains/%d/passwd | |
} | |
---- | |
--- 5th step --- | |
open /etc/dovecot/conf.d/10-master.conf | |
edit to this | |
---- | |
service imap-login { | |
inet_listener imap { | |
address = 127.0.0.1 | |
} | |
inet_listener imaps { | |
} | |
} | |
service pop3-login { | |
inet_listener pop3 { | |
address = 127.0.0.1 | |
} | |
inet_listener pop3s { | |
} | |
} | |
---- | |
--- 6th step --- | |
open /etc/exim4/exim4.conf.template | |
find this section > | |
###################################################################### | |
# AUTHENTICATION CONFIGURATION # | |
###################################################################### | |
-- | |
change the content to this | |
###################################################################### | |
# AUTHENTICATION CONFIGURATION # | |
###################################################################### | |
begin authenticators | |
cram_md5: | |
driver = cram_md5 | |
public_name = CRAM-MD5 | |
client_name = ${extract{1}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}} | |
client_secret = ${extract{2}{:}{${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}}} | |
# this returns the matching line from passwd.client and doubles all ^ | |
PASSWDLINE=${sg{\ | |
${lookup{$host}nwildlsearch{CONFDIR/passwd.client}{$value}fail}\ | |
}\ | |
{\\N[\\^]\\N}\ | |
{^^}\ | |
} | |
#dovecot_plain: | |
# driver = dovecot | |
# public_name = PLAIN | |
# server_socket = /var/run/dovecot/auth-client | |
# server_set_id = $auth1 | |
#dovecot_login: | |
# driver = dovecot | |
# public_name = LOGIN | |
# server_socket = /var/run/dovecot/auth-client | |
# server_set_id = $auth1 | |
----------------------------------------- | |
--- 7th step --- | |
mv /usr/local/vesta/ssl/certificate.crt /usr/local/vesta/ssl/unusablecer.crt | |
mv /usr/local/vesta/ssl/certificate.key /usr/local/vesta/ssl/unusablecer.key | |
ln -s /home/admin/conf/web/ssl.naizu-ro.com.pem /usr/local/vesta/ssl/certificate.crt | |
ln -s /home/admin/conf/web/ssl.naizu-ro.com.key /usr/local/vesta/ssl/certificate.key | |
chgrp mail /home/admin/conf/web/ssl.naizu-ro.com.key | |
chmod 660 /home/admin/conf/web/ssl.naizu-ro.com.key | |
chgrp mail /home/admin/conf/web/ssl.naizu-ro.com.pem | |
chmod 660 /home/admin/conf/web/ssl.naizu-ro.com.pem | |
chgrp mail /home/admin/conf/web/ssl.naizu-ro.com.crt | |
chmod 660 /home/admin/conf/web/ssl.naizu-ro.com.crt | |
--- 7th step --- | |
in terminal | |
service exim4 restart | |
service apache2 restart | |
service dovecot restart | |
service vesta restart | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment