1 (edited by Blocker 2015-02-04 09:58:19)

Topic: Migrating from 0.8.7 to new server build

==== Required information ====
- iRedMail version: 0.8.7
- Store mail accounts in which backend (MySQL):
- Linux/BSD distribution name and version: CentOS 6.6
- Related log if you're reporting an issue:
====

HI,
Am curious as to whether the article here: http://www.iredmail.org/docs/migrate.to … erver.html is still current with the new version 0.9.x

I want to completely rebuild my iRedmail server from scratch as I am currently using Horde as the web interface and I want to enable both Roundcube and SOGo.

Should I upgrade my 0.8.7 version first then follow the steps in the migrate guide ?

With thanks..

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Migrating from 0.8.7 to new server build

Yes, it works with iRedMail-0.9.0.

Blocker wrote:

Should I upgrade my 0.8.7 version first then follow the steps in the migrate guide ?

It's better to upgrade to the latest iRedMail-0.9.0, then migrate.

Check our upgrade tutorials here:
http://www.iredmail.org/docs/iredmail.releases.html

3 (edited by Blocker 2015-02-04 18:34:12)

Re: Migrating from 0.8.7 to new server build

Thanks Zhang,

So the steps are:
1. Upgrade iRedMail and iRedAdminPro to latest versions
2. install SOGo
3. Build new server with SOGo as part of install and then migrate vmail database and mail files from existing to new server ?

With thanks..

4

Re: Migrating from 0.8.7 to new server build

Blocker wrote:

So the steps are:
1. Upgrade iRedMail and iRedAdminPro to latest versions
2. install SOGo
3. Build new server with SOGo as part of install and then migrate vmail database and mail files from existing to new server ?

Step 2 is unnecessary. Other 2 are ok.

5 (edited by Blocker 2015-02-14 13:08:45)

Re: Migrating from 0.8.7 to new server build

ZhangHuangbin wrote:
Blocker wrote:

So the steps are:
1. Upgrade iRedMail and iRedAdminPro to latest versions
2. install SOGo
3. Build new server with SOGo as part of install and then migrate vmail database and mail files from existing to new server ?

Step 2 is unnecessary. Other 2 are ok.

Hi,

Completed step 1 without issue all good.
Built new server with SOGO included then dumped vmail database into new server build. Checked normal mail ops all working as well as iRedAdmin-Pro.. All working as intended, however users cannot log into SOGo webmail, simply says "Wrong username or password". Am I missing something here ?

With thanks..


[edit] I get this message in the sogo.log :
sogod [3151]: SOGoRootPage Login from 'localhost' for user 'email address here' might not have worked - password policy: 65535  grace: -1  expire: -1  bound: 0

I see no other error messages in any other logs.. It's like SOGo cannot auth against the vmail database for some reason.

6

Re: Migrating from 0.8.7 to new server build

SOGo authenticates through a MySQL View inside its own Schema, could you list all Tables/Views in the SOGo Schema for us?

7

Re: Migrating from 0.8.7 to new server build

Try to reset password for this user, then try again.

8

Re: Migrating from 0.8.7 to new server build

ZhangHuangbin wrote:

Try to reset password for this user, then try again.

He said users, suggesting all users not just a specific one hmm

9 (edited by Blocker 2015-02-15 11:09:14)

Re: Migrating from 0.8.7 to new server build

Hi guys,

Yes it is affecting ALL users. I just deleted the sogo database and database user from mysql and built it back up using the instructions found here:
http://www.iredmail.org/docs/sogo-centos-6-mysql.html

Now if I manually reset the password in iRedAdmin-Pro it works fine, however that option is not viable for me as I have hundreds of users and the passwords for them are hashed in the database, so I cant see them anyway even if I did want to reset them manually.

I have also manually looked at the hashed passwords in both the old vmail database and the new and they are both the same (as they should be) I also looked at the password hash as stored in the view for sogo and it also matches the one in the vmail database.

I'm at a bit of a loss here as to why I cannot get sogo to auth against the vmail database without needing to reset the users password. Even though I rebuilt the sogo database from scratch as shown in the link above.

I'm thinking it may be easier to just run with Roundcube for the time being.

With thanks..

10

Re: Migrating from 0.8.7 to new server build

Blocker wrote:

Hi guys,

Yes it is affecting ALL users. I just deleted the sogo database and database user from mysql and built it back up using the instructions found here:
http://www.iredmail.org/docs/sogo-centos-6-mysql.html

Now if I manually reset the password in iRedAdmin-Pro it works fine, however that option is not viable for me as I have hundreds of users and the passwords for them are hashed in the database, so I cant see them anyway even if I did want to reset them manually.

I have also manually looked at the hashed passwords in both the old vmail database and the new and they are both the same (as they should be) I also looked at the password hash as stored in the view for sogo and it also matches the one in the vmail database.

I'm at a bit of a loss here as to why I cannot get sogo to auth against the vmail database without needing to reset the users password. Even though I rebuilt the sogo database from scratch as shown in the link above.

I'm thinking it may be easier to just run with Roundcube for the time being.

With thanks..

Stupidly sogo doesn't authenticate against dovecot directly, could you give me an example of a hash? (safest, change your password to password, copy hash from db then change it back)

11

Re: Migrating from 0.8.7 to new server build

Is it possible to let me login to your server for further debug? This issue was reported by another user before, and resetting password works for him/her too. I'm curious what the root cause is.

12

Re: Migrating from 0.8.7 to new server build

7t3chguy wrote:
Blocker wrote:

Hi guys,

Yes it is affecting ALL users. I just deleted the sogo database and database user from mysql and built it back up using the instructions found here:
http://www.iredmail.org/docs/sogo-centos-6-mysql.html

Now if I manually reset the password in iRedAdmin-Pro it works fine, however that option is not viable for me as I have hundreds of users and the passwords for them are hashed in the database, so I cant see them anyway even if I did want to reset them manually.

I have also manually looked at the hashed passwords in both the old vmail database and the new and they are both the same (as they should be) I also looked at the password hash as stored in the view for sogo and it also matches the one in the vmail database.

I'm at a bit of a loss here as to why I cannot get sogo to auth against the vmail database without needing to reset the users password. Even though I rebuilt the sogo database from scratch as shown in the link above.

I'm thinking it may be easier to just run with Roundcube for the time being.

With thanks..

Stupidly sogo doesn't authenticate against dovecot directly, could you give me an example of a hash? (safest, change your password to password, copy hash from db then change it back)

Sure, here is the password as it is stored in the vmail database, in the mailbox table:
{SSHA512}Ldk+DF3n2uk2yOu2XZlfAz8XMSXC3i/7F4EWepYozSPgG8iMA0P9x4+avK1/0ZJvy8VNBExFW86O3NZVM1VrTRj6Z+y9bnph

and here it is as it is stored in the sogo database under the users view:
{SSHA512}Ldk+DF3n2uk2yOu2XZlfAz8XMSXC3i/7F4EWepYozSPgG8iMA0P9x4+avK1/0ZJvy8VNBExFW86O3NZVM1VrTRj6Z+y9bnph

They are exactly the same..

13 (edited by Blocker 2015-02-16 08:07:47)

Re: Migrating from 0.8.7 to new server build

ZhangHuangbin wrote:

Is it possible to let me login to your server for further debug? This issue was reported by another user before, and resetting password works for him/her too. I'm curious what the root cause is.

Yep, I can do that. If you send me an email (details are in my profile and should be available to you) I will reply with the details.

Please be aware that I have blocked some IP addresses from China due to continued attempts to bypass my security. Let me know when you have sent an email.

With thanks..

14

Re: Migrating from 0.8.7 to new server build

Dear @Blocker,

I sent an email to you moment ago, please let me know if you didn't receive it.

15

Re: Migrating from 0.8.7 to new server build

Blocker wrote:
7t3chguy wrote:
Blocker wrote:

Hi guys,

Yes it is affecting ALL users. I just deleted the sogo database and database user from mysql and built it back up using the instructions found here:
http://www.iredmail.org/docs/sogo-centos-6-mysql.html

Now if I manually reset the password in iRedAdmin-Pro it works fine, however that option is not viable for me as I have hundreds of users and the passwords for them are hashed in the database, so I cant see them anyway even if I did want to reset them manually.

I have also manually looked at the hashed passwords in both the old vmail database and the new and they are both the same (as they should be) I also looked at the password hash as stored in the view for sogo and it also matches the one in the vmail database.

I'm at a bit of a loss here as to why I cannot get sogo to auth against the vmail database without needing to reset the users password. Even though I rebuilt the sogo database from scratch as shown in the link above.

I'm thinking it may be easier to just run with Roundcube for the time being.

With thanks..

Stupidly sogo doesn't authenticate against dovecot directly, could you give me an example of a hash? (safest, change your password to password, copy hash from db then change it back)

Sure, here is the password as it is stored in the vmail database, in the mailbox table:
{SSHA512}Ldk+DF3n2uk2yOu2XZlfAz8XMSXC3i/7F4EWepYozSPgG8iMA0P9x4+avK1/0ZJvy8VNBExFW86O3NZVM1VrTRj6Z+y9bnph

and here it is as it is stored in the sogo database under the users view:
{SSHA512}Ldk+DF3n2uk2yOu2XZlfAz8XMSXC3i/7F4EWepYozSPgG8iMA0P9x4+avK1/0ZJvy8VNBExFW86O3NZVM1VrTRj6Z+y9bnph

They are exactly the same..

Do the non-functional hashes 'look' different? Different prefix or whatever?

16

Re: Migrating from 0.8.7 to new server build

7t3chguy wrote:

Do the non-functional hashes 'look' different? Different prefix or whatever?

Actually yes, the non-functional accounts are missing the {SSHA512} from the front, however the hash's themselves are identical.

Maybe it needs the {SSHA512} at the front in both locations ?

Thanks...

17

Re: Migrating from 0.8.7 to new server build

Blocker wrote:
7t3chguy wrote:

Do the non-functional hashes 'look' different? Different prefix or whatever?

Actually yes, the non-functional accounts are missing the {SSHA512} from the front, however the hash's themselves are identical.

Maybe it needs the {SSHA512} at the front in both locations ?

Thanks...

SOGo conforms to that properly so yeah, it reads which hash it should use from that {SSHA512} part, it looks like your hashes were created in a system which didn't do this. Want me to write you a MySQL Snippet which will convert all Passwords Hashes to the Prefixed format?
By the way, the View mirrors the vmail.mailboxes table so just change it in vmail.mailboxes and the view will be updated also.

18

Re: Migrating from 0.8.7 to new server build

7t3chguy wrote:
Blocker wrote:
7t3chguy wrote:

Do the non-functional hashes 'look' different? Different prefix or whatever?

Actually yes, the non-functional accounts are missing the {SSHA512} from the front, however the hash's themselves are identical.

Maybe it needs the {SSHA512} at the front in both locations ?

Thanks...

SOGo conforms to that properly so yeah, it reads which hash it should use from that {SSHA512} part, it looks like your hashes were created in a system which didn't do this. Want me to write you a MySQL Snippet which will convert all Passwords Hashes to the Prefixed format?
By the way, the View mirrors the vmail.mailboxes table so just change it in vmail.mailboxes and the view will be updated also.

Well I'm going to have a crack it myself first, although I expect anything you do will be more efficient and or elegant than anything I might throw together. It would be beneficial to include it in the upgrade instructions so others don't have the same issue. My hashes were created by iRedMail 0.8.7 so including a mysql snippet in the upgrade docs for adding the hash type would be great..

Thanks.

19

Re: Migrating from 0.8.7 to new server build

Ok here's an update. Simply adding {SSHA512} to the front of the password hash created in iRedMail version0.8.7 will not work. It seems version 0.8.7 used the {CRYPT} hash type so you need to add {CRYPT} instead of {SSHA512}

iRedAdmin-Pro uses by default {SSHA} when you change a password and SOGo will accept both.. I created a mysql function which simply concats the {CRYPT} and the existing hash. Then I just use that function in a simple update query to change all passwords, or supply a where statement on the username to change just one password.

If people want I can post the function here?

20

Re: Migrating from 0.8.7 to new server build

Ah, makes sense, when you said they look the same but without the prefix you probably didn't take into account the length, glad you got your issue worked out

21 (edited by Blocker 2015-02-17 14:51:51)

Re: Migrating from 0.8.7 to new server build

7t3chguy wrote:

Ah, makes sense, when you said they look the same but without the prefix you probably didn't take into account the length, glad you got your issue worked out

Thanks, but the real credit must go to Zhang, he did the actual debug and found the incompatibility between SOGo and non prefixed MD5 hashes.

If anyone is interested here is the function for changing the existing passwords from a 0.8.7 vmail database.

DELIMITER //
CREATE FUNCTION pchange (pword varchar(255)) RETURNS varchar(255)
BEGIN
    RETURN CONCAT ('{CRYPT}', pword);
END; //
DELIMITER ;

You must have root access to your database. Once you are at the mysql prompt change to the vmail database. Then copy the function above and paste at the mysql prompt. You will be left with the cursor flashing after the DELIMITER ; line. Simply press enter here and you will be back at the mysql prompt.

To use the function to change all passwords use an update query like so:
update mailbox set password=pchange(password);

To change a single password use:
update mailbox set password=pchange(password) where username='user@domain';

22

Re: Migrating from 0.8.7 to new server build

To be more clear: looks like SOGo doesn't support salted MD5 password hash which doesn't has a '{CRYPT}' prefix, for example:

$1$GfHYI7OE$vlXqMZSyJOSPXAmbXHq250

But it works if you prefix correct password schema name in password hash. For example, salted MD5 is supported by system crypt lib, so we can use prefix '{CRYPT}' prefix to let sogo clearly know which password encryption algorithm it's used to generate this password hash:

$1$GfHYI7OE$vlXqMZSyJOSPXAmbXHq250

SSHA ({SSHA}), ssha512 ({SSHA512}), bcrypt ({CRYPT}) and others work the same way in sogo, iredadmin, Dovecot.