Lost Machine Key, can't log in

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
2/21/2011 6:51:36 PM
Gravatar
Total Posts 11

Lost Machine Key, can't log in

After having a few issues, and re-uploading the web site from Microsoft WebMatrix, I find I've overwritten the machine key which the installer script generated for me and I can't log in as admin or anyone else.  How do I recover from that without losing the whole site!  Apart from that the site is working as it was (at last).

Help!,

Colin Begg

 

2/21/2011 9:52:47 PM
Gravatar
Total Posts 47

Re: Lost Machine Key, can't log in

If you cannot login, then it seems to be a database issue.

You can regenerate the machinekey copy it ,search for 'machinekey' in web.config and replace machinekey element in web.config

2/21/2011 10:29:53 PM
Gravatar
Total Posts 2253

Re: Lost Machine Key, can't log in

Hi Colin,

The machineKey is used to encrypt passwords (among other things). You can not just generate a new machineKey because the new key will not be able to decrypt the previously stored passwords and you will be in the same boat you are in currently.

If you created a backup of your site files prior to upgrading, grab the custom machineKey out of the web.config file from your backup and put it in your current web.config.

If you don't have a backup, and your configuration allows resetting passwords, give that a try.

Let me know if that doesn't get you back into your site and I will post a detailed step-by-step on resetting your machineKey and resetting all passwords in your db to plaintext and then back to encrypted. This process will cause all passwords to be changed on your site but if you don't have the custom machineKey they were encrypted with, there is no other option really.

HTH,
Joe D.

2/21/2011 10:45:23 PM
Gravatar
Total Posts 47

Re: Lost Machine Key, can't log in

Thanks Joe for the correction. I thought he may have replaced the SQLite or SLQCE database  by mistake instead with an old version without user details.

2/22/2011 1:02:31 AM
Gravatar
Total Posts 11

Re: Lost Machine Key, can't log in

If I try 'Recover Password' option, after entering my user name (Admin), I get the following error page:

Colin

We're sorry but a server error has occurred while trying to process your request.

The error has been logged and will be reviewed by our staff as soon as possible. It is possible that the error was just a momentary hiccup and you may wish to use the back button and try again or go back to the home page.

2/22/2011 1:08:51 AM
Gravatar
Total Posts 47

Re: Lost Machine Key, can't log inSee the

View the file 'currentlog.config' under the 'data' folder, it should have the error at the bottom.

2/22/2011 2:43:38 AM
Gravatar
Total Posts 11

Re: Lost Machine Key, can't log in

Surprise, surprise, the error was:

So I'll wait for Joe's detailed procedure!

 

Thanks,

Colin

2011-02-22 07:00:03,454 ERROR mojoPortal.Web.Global - 82.7.232.66-en-GB - /Secure/RecoverPassword.aspx
System.Web.HttpException: Unable to validate data.
   at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo, Boolean signData)

2/22/2011 6:18:15 AM
Gravatar
Total Posts 18439

Re: Lost Machine Key, can't log in

Hi Colin,

The only way to get back in is to change back to clear text passwords directly in the database. Then once you are back in you can generate a new machine key and then you can switch to encrypted passwords. Then of course going forward you need to be very careful to keep that custom machine key the same, so whenever you upgrade you need to backup the Web.config file and restore the machine key to the new one.

Steps to recover:

  1. UPDATE mp_Sites SET PasswordFormat = 0
  2. UPDATE mp_Users SET Pwd = 'changeme'
  3. touch Web.config to recycle the app or if you have a way to recycle from the web control panel do that (just to clear the site settings cache)

Now you can login with the password changeme (for all existing users). Once you login you should of course change the password.

Then before changing back to encrypted passwords make sure you have a new machine key and have this machine key backed up somewhere.

Hope it helps,

Joe

2/22/2011 7:22:50 AM
Gravatar
Total Posts 11

Re: Lost Machine Key, can't log in

Excellent, Joe,

   All done in my lunch hour (and a bit!).  The second (newer) link in web.config doesn't work, so I used the first one and it works OK.

New key is stored away and passwords changed.

 

Lots of thanks,

Colin Begg, adminning again!

2/23/2011 12:26:06 PM
Gravatar
Total Posts 18439

Re: Lost Machine Key, can't log in

Thanks for reminding me about those links in Web.config, the comments were outdated, I am updating those comments now to mention that we have a built in tool for generating a machine key at Administration > Security Advisor.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.