Mailboxes Auto Login for ispconfog administrators

Discussion in 'Tips/Tricks/Mods' started by adammazin, Oct 4, 2019.

  1. adammazin

    adammazin New Member

    Hello guys,
    finally i got it work, I'm not programmer so i hope programmers help make it easier for others. i did it because my clients was nagging since i moved them from Cpanel to awesome Ispconfig to give them ability for auto login to other mailboxes without remembering or resetting mailbox passwords. so steps like below:
    Step One: create dovecot master password following these instructions: https://wiki1.dovecot.org/Authentication/MasterUsers
    changes will be done here /etc/dovecot/dovecot.conf
    like below:
    PHP:
    auth_master_user_separator = :
    passdb {
        
    args = /etc/dovecot/dovecot-master-users
        master 
    yes
        pass 
    yes
        driver 
    passwd-file
      
    }
    you can use another separators as you like " _ , - , +" just don't use "*"
    and you have to create this file /etc/dovecot/dovecot-master-users and but master password inside like below
    Code:
    admin:{SSHA512}PUTMdnfsflskjdctsLobSmGEndfklsdjk9WSaiHnudjflksjdskjsF2eJkjdhsddjslkdfjlV/BbSJ5M3BXOChEpo=
    to create master password like above use this CLI command
    Code:
    doveadm pw -s SSHA512
    keep in mind this text {SSHA512} is important read instruction.
    don't forget to restart dovecot
    Code:
    service dovecot restart
    keep this password save or simply don't keep it on your PC use it and forget it, if anyone got them you and your clients will be hacked :D
    before i forget change file permission
    Code:
    chown root:dovecot /etc/dovecot/dovecot-master-users
    chmod 644 /etc/dovecot/dovecot-master-users
    Step Two: you have to play with ispconfig files :rolleyes: so go and add below lines to /var/www/ispconfig/mail/webmailer.php after line 59 and right after
    Code:
           $webmail_url = str_replace('[SERVERNAME]', $serverData['server_name'], $webmail_url);
    
    lines to add:
    Code:
    include "/var/www/ispconfig/mail/RoundcubeLogin.class.php";
    $dbemail = $app->db->queryOneRecord("SELECT email FROM mail_user WHERE mailuser_id = ?", $emailId);
    $rcl = new RoundcubeLogin("/roundcube/", $debug);
    $rcl->setHostname($serverData['server_name']);
    $rcl->setPort(80);
    $rcl->setSSL(false);
    $rcl->logout();
    try {
            $rcl->login($dbemail['email'].":admin", "Your PLAIN Password");
            $rcl->redirect();
    }
    catch (RoundcubeLoginException $ex) {
     echo "ERROR: Technical problem, ".$ex->getMessage();}
    
    and replace "Your PLAIN Password" on above code with your plain master password you created earlier, remember plain not encrypted. and you have to comment out this line
    Code:
    //      header('Location:' . $webmail_url);
    Then go and create this file /var/www/ispconfig/mail/RoundcubeLogin.class.php on same directory like you see, fill it with code from this file https://blog.heckel.io/wp-content/uploads/2008/05/RoundcubeLogin.class.php.txt or or just download file and upload it to above directory.
    ***All thanks after Brilliant Ispconfig Team to this guy Philipp C. Heckel and his script find it here: https://blog.heckel.io/2008/05/16/roundcube-login-via-php-script/
    after creating it don't forget to change file permission:
    Code:
    chown -R ispconfig:ispconfig /var/www/ispconfig/mail/RoundcubeLogin.class.php

    Now go and test your new feature ;)
     
    Last edited: Nov 15, 2019
  2. recin

    recin Active Member

    Thanks. It works like a charm.
    Only 2 notes:
    • You dont need -R when doing chown to a file
    • When adding lines to ispconfig webmailer.php file, note you can't do it in the end of the file, they should be before the exit in the last line
     
  3. recin

    recin Active Member

    After step one, you could try if it works accessing webmail with any mail created followed by :admin and the plain master password
     
  4. adammazin

    adammazin New Member

    thank you for replying and helpful comments, you are right , i did edit the post
     
  5. adammazin

    adammazin New Member

    ya it work, test it by yourself
     
  6. recin

    recin Active Member

    I wanted to mean you could add this info in the original post, just to be sure that the postfix password is OK before start playing with ispconfig files.

    On the other hand, how could we keep this changes after ispconfig upgrades?
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Use Internet Search Engines with
    Code:
    site:howtoforge.com ispconfig conf-custom
     
    adammazin likes this.
  8. Alan de Almeida

    Alan de Almeida New Member

    Using this method, perceived, despite getting access, it is not possible to send e-mails, since the user's master does remain in the user's e-mail. Does anyone know any solution for this?
    Example:
    [email protected]:admin

    [​IMG]
     
  9. recin

    recin Active Member

    Just clic "editar identidades" next to the from, and delete the :admin.
    You should do this only once time for every account
     
    Alan de Almeida likes this.
  10. Alan de Almeida

    Alan de Almeida New Member

    It worked! Thanks.
    I was already looking for another solution. :D:D:D
     
  11. Alan de Almeida

    Alan de Almeida New Member

    Another doubt. With this method the user is unable to log into the roundcube using the common address: example.com/webmail, only through the control panel.

    When accessing the common address and testing the login, the roundcube does not return login failure. Any suggestion?
     
  12. recin

    recin Active Member

    Normal webmail access shouldn't have any problem.
    If you want to access with the master password you should append :admin to user mail on roundcube login screen
     
    Alan de Almeida likes this.
  13. Alan de Almeida

    Alan de Almeida New Member

    It's working. It was a mistake of mine. Thanks!
     

Share This Page