ispconfig email login with user@domain How to

Discussion in 'Tips/Tricks/Mods' started by desmondk, Nov 2, 2006.

  1. falko

    falko Super Moderator Howtoforge Staff

    I'm using Debian on my servers, but Ubuntu is a good choice as well.


    It is a good distribution, but apt is superior to rpm.

    I got lots of negative feedback from Mandriva users (fanboys?) saying that apt is not needed when you have "such a good tool as urpmi", etc. :rolleyes: I also used apt for a SuSE and a Fedora howto, but SuSE/Fedora users didn't like that, too, so I decided to use each distro's original package management tools again.
    From many years of experience I know that apt is better, but because of such negative feedback I leave it to the users to find it out themselves. :p
     
  2. Morons

    Morons Member

    ROFLMAO !

    Thank you for your candour in this matter. I do however know that there are basic differences in directory / folder layout between debian-like and Redhat-like distro's - To be honest I'll be lost in the debian one, however I believe debian to be the favourite amongst many "Linutic's. I will do my best to adopt on this server and maybe it works for me better - Here goes - Perfect debian

    P.S. I'm Proudly South African and Ubuntu is the local brand but... I duno
     
  3. ars

    ars New Member

    Great Script for username as domainname will not work

    Hello to all,

    I'm new here an first I have to say ISPconfig ist a really good configuration tool an the scripts in this thread are very good for customers. :) Thanks for this.
    But, yesterday I have tested the versions are posted here. I take the script from Desmondk. It works, but courier does not accept the Username as "[email protected]" If I use the origin name from ispconfig everything works.
    If I take the script from rojozak the output is empty in "userdb". :confused:

    My System is a Debian 3.1 My setup has followed the perfect Debian Setup for ispconfig.

    For any suggestions many thanks. :)

    ars
     
  4. Morons

    Morons Member

    Yes look at the script and the loaction of the userdb and look were your courier installed, /etc/userdb vs /etc/courier/userdb I guess to make courier work is to use the userdb installed by courier, thus chang the script to generate it at the correct path.
     
  5. ars

    ars New Member

    Great Script for username as domainname will not work

    Hello Morons,

    thanks for your answer.
    I have changed the script from rozojak, so that the script writes the output to "/etc/courier/userdb"
    The output in the "userdb" as follow:
    "[email protected] uid=10005|gid=10006|home=/var/www/web6/user/xyx|shell=/dev/null|systempw=xyz|/var/www/www.xyz.de/user/xyz.de/Maildir"
    in one line.

    After creating the userdb.dat and the userdbshadow.dat with the "makeuserdb" command I cannot login with "[email protected]"
    Is the line in the userdb correct?
    In "authdaemonrc" the authuserdb module is activ.

    Thanks for your reply

    ars
     
  6. Morons

    Morons Member

    After playing around I installed ubuntu 6.10. It is / was fun - Mandriva does a Lot more to make things GUI ubuntu server has no gui install and lots more files need to be edited [I detest using other editors other than vim in cases like crontab -e some other wordstar like editor loads instead of vim] also the strain of vi is old and causes me to make errors! However the system is fast [Mandriva is compiled for 586 ubuntu 386] but i'm adapting as i find more application support from developers like backuppc that wes written in debian that is now easy to locate the config files and stuff without effort.
    But thats early times and my opinion. The problems is superficial and can be adopted to.

    I did a new install and found Exactly the results of member ars,
    Code:
    root@beta:/etc# telnet localhost 110
    Trying 127.0.0.1...
    Connected to localhost.localdomain.
    Escape character is '^]'.
    +OK Hello there.
    user [email protected]
    +OK Password required.
    pass test
    -ERR Login failed.
    quit
    +OK Better luck next time.
    the /etc/courier/userdb.dat does contain
    Code:
    [email protected] uid=10002|gid=10001|home=/var/www/web1/user/domain.tld_test|shell=/bin/false|systempw=mXsanitizedz2h3YjVU|/var/www/www.domain.tld/user/domain.tld_test/Maildir1
    However the normal works
    Code:
    root@beta:/etc# telnet localhost 110
    Trying 127.0.0.1...
    Connected to localhost.localdomain.
    Escape character is '^]'.
    +OK Hello there.
    user domain.tld_test
    +OK Password required.
    pass test
    +OK logged in.
    I'm still searching logfiles to try and locate the issue.
     
  7. Morons

    Morons Member

    Found in /var/log/mail.info
    Code:
    Jan 31 12:09:17 beta courierpop3login: LOGIN FAILED, [email protected], ip=[::ffff:127.0.0.1]
    Jan 31 12:09:32 beta courierpop3login: LOGOUT, ip=[::ffff:127.0.0.1]
    and the next one
    Code:
    Jan 31 12:12:57 beta courierpop3login: LOGIN, user=domain.tld_test, ip=[::ffff:127.0.0.1]
    Jan 31 12:14:20 beta courierpop3login: LOGOUT, user=domain.tld_test, ip=[::ffff:127.0.0.1], top=0, retr=0, rcvd=6, sent=30, time=83
    This matches the test above.
    In user.log i get what seem to be syptoms
    Code:
    Jan 31 12:12:57 beta authdaemond: PAM unable to dlopen(/lib/security/pam_foreground.so)
    Jan 31 12:12:57 beta authdaemond: PAM [dlerror: /lib/security/pam_foreground.so: undefined symbol: pam_set_data]
    Jan 31 12:12:57 beta authdaemond: PAM adding faulty module: /lib/security/pam_foreground.so
    I hope to find the solution by googling
     
  8. Morons

    Morons Member

    Finally Debugged!

    :) I eventually got the debug working, and the problems dissapeared in a jiffy!

    http://www.courier-mta.org/authlib/?README.authdebug.html

    Basically add the line DEBUG_LOGIN=2 to your authdaemonrc config file. Also add *.debug /var/log/debug to /etc/syslog.conf even if there is one saying *.=debug

    I set ISPC to use maildir and created some sites.
    My system is ubuntu 6.10 [following falko's advice] and ISPC 2.2.9:)
     
    Last edited: Feb 9, 2007
  9. ars

    ars New Member

    Thanks for your help

    :) Hello Morons,

    I've solved the problem.

    It was a "copy and paste" Problem.
    After the echo command that creates the userdb a tab is needed not a space.
    Now it works.

    Thanks a lot

    ars
     
  10. rojozak

    rojozak New Member

    Yes...a <Tab> is required immediately following the address in userdb. The biggest problem I had getting this script to work was the proper format of userdb because of copy/paste. Refer to

    Code:
    man userdb
    for the proper format. During testing I would pipe the output to a junk file to check the format before finalizing, comparing to an existing (working) userdb if necessary. That's what finally got me the working script I posted earlier in this thread. It has been working solid in production for over 3 months now with no problems.

    Remember though...this does not change your user login for ISPConfig access (ie FTP). That username remains as XXX.DOM_username.
     
  11. porjo

    porjo New Member

    This works for me...however...

    On Centos 4.4 , the 0.99 version of Dovecot included doesn't support the 'auth_username_format' option. You need Dovecot v1.0.x

    1. remove the old Dovecot 0.99 RPM - 'rpm -e dovecot'
    2. Download and install new Dovecot 1.0.x RPM from ATrpm e.g:
    "rpm -ivh http://dl.atrpms.net/all/dovecot-1.0-3_47.rc24.el4.at.x86_64.rpm"
     
  12. TimeJunky

    TimeJunky New Member

    hello,

    how to handle this? - Registred to emails with ISPC on different domains but same main-name 'register'

    [email protected]
    [email protected]

    Now, I am getting this error:

    Cannot store record for register - duplicate or out of disk space.
    Cannot store record for register - duplicate or out of disk space.
    Cannot create /etc/courier/userdbshadow.tmp
    Cannot store record for register - duplicate or out of disk space



    Script iscp-courier-convertion :
    ..............................................
    #!/bin/bash
    # http://www.howtoforge.com/forums/showthread.php?t=7881&highlight=mailuser

    delim="_"

    OIFS=$IFS
    IFS="
    "
    rm -rf /etc/courier/userdb
    touch /etc/courier/userdb
    chmod 600 /etc/courier/userdb
    for line in `/usr/sbin/pw2userdb | grep -ir user`
    do
    full=$( echo $line )
    domain=$( echo $line | cut -d"$delim" -f1 )
    remain=$( echo $line | cut -d"$delim" -f2,3,4 )
    username=$( echo $remain | cut -d ' ' -f1 )
    remain2=$( echo $remain | cut -d ' ' -f2 )
    uid=$( echo $remain2 | cut -d '|' -f1 )
    gid=$( echo $remain2 | cut -d '|' -f2 )
    home=$( echo $remain2 | cut -d '|' -f3 )
    shell=$( echo $remain2 | cut -d '|' -f4 )
    password=$( echo $remain2 | cut -d '|' -f5)
    echo "$username@$domain $uid|$gid|$home|$shell|$password|/var/www/www.$domain/user/${domain}_$username/Maildir" >> /etc/courier/userdb
    /usr/sbin/makeuserdb
    done
    IFS=$OIFS
     
  13. advinser

    advinser New Member

    Hi,

    I try the solutions of desmondk with the correction of rojozak.

    If I run manualy the script (I put it in my /usr/sbin/ folder and I rename it my_email ) it doesn't return errors and it execute.

    But if I try to login with [email protected] i receive an error from my client.

    Can you explain me: I add a new user than I run the script, but the script from where take the user datails?
    The file /etc/courier/userdb is always empty (also if I comment the line makeuserdb in the script).

    Can you suggest me a debug solutions? I'm not able with linux but I have to understand.

    Thank you.

    Andrea
     
  14. TimeJunky

    TimeJunky New Member

    now, it is running again after small correction :)

    As former told by users like ars, the spaces in
    username=$(echo $remain | cut -d " " -f1 )
    have to be replaced with a tab. Unfortunatelley, debian was complaining afterwards, so I took the delemiter >"< instead of >' < to get it working.

    Code:
    #!/bin/bash
    # http://www.howtoforge.com/forums/showthread.php?t=7881&highlight=mailuser
    
    delim="_"
    
    OIFS=$IFS
    IFS="
    "
    rm -rf /etc/courier/userdb
    touch /etc/courier/userdb
    chmod 600 /etc/courier/userdb
    for line in `/usr/sbin/pw2userdb | grep -ir user`
     do
       full=$( echo $line )
       domain=$( echo $line | cut -d"$delim" -f1 )
       remain=$( echo $line | cut -d"$delim" -f2,3,4 )
       username=$(echo $remain | cut -d "   " -f1 ) # tab inside
       remain2=$(echo $remain | cut -d "    " -f2 ) # tab inside
       uid=$( echo $remain2 | cut -d '|' -f1 )
       gid=$( echo $remain2 | cut -d '|' -f2 )
       home=$( echo $remain2 | cut -d '|' -f3 )
       shell=$( echo $remain2 | cut -d '|' -f4 )
       password=$( echo $remain2 | cut -d '|' -f5)
       echo "$username@$domain $uid|$gid|$home|$shell|$password|/var/www/www.$domain/user/${domain}_$username/Maildir" >> /etc/courier/userdb
       /usr/sbin/makeuserdb
     done
    IFS=$OIFS
    @Andrea
    The script is creating first data with the command /usr/sbin/pw2userdb
    Remember, that it takes 5 Minutes to update the dababase and don't forget to initialize new mailboxes with a mail.
     
  15. advinser

    advinser New Member

    Ok, but I can login with the domain.tld_user but not with [email protected]

    How to verify the correct iter of the script?

    If the script work, how can I understand?

    Thx!!!
     
  16. TimeJunky

    TimeJunky New Member

  17. advinser

    advinser New Member

  18. TimeJunky

    TimeJunky New Member

    access with clients are not a problem.
    user: domain_user
    pw: yours
     
  19. advinser

    advinser New Member

    I think you don't understand my problem: I want access with my email client to the mail not usign the domain.tld_user + pwd but using [email protected] + pwd like other system (ensim, plesk, etc.)

    The method in this post is not for this problem???
     
  20. rojozak

    rojozak New Member

    Check paths and Use courierauthtest command

    advinser,

    If your userdb file is empty, something is not right. check your paths on your system against the paths in the script. the paths that i used were based on my install which was the Ubuntu 6.06 Perfect Setup. In other words, your setup may vary.

    Also, are you absolutely certain you replaced spaces with tabs when copying/pasting the script from this website?

    Once you confirm that you have users in the userdb file, the script should have created the userdb.db file. Then you can confirm that the userdb file is formated correctly by using:

    Code:
    courierauthtest [email protected]
    If it worked, it will give you userid and other info. If it fails, it will tell you that authentication failed.

    Finally, you can use the same test with the password:

    Code:
    courierauthtest [email protected] password
    and again check for pass/fail. If it passes here, you are good to go.

    Finally, (remember, it won't work until you've gotten as far as above. But then there are only certain applications that you can use this method in. (ie those that use courier for authentication). It will not work as a login for ISPConfig.

    Good Luck.
     

Share This Page