MFA Not Working after Restoring Home Assistant Snapshot

I am moving my HA build from one device (Windows) to another (MacOS)…

Since both devices run in Virtualbox, my initial thought was to just use the VDI file from the old machine, in the new one, but this didn’t work (still not sure why, but that’s a different topic all on it’s own).

Then I thought I’d use my snapshot and just restore it on the new machine.

This worked fine and HA boots up and I need to put in my Username and Password, then do MFA.

At the MFA stage, I put in the 6 digits from the Authenticator app and it just says

Invalid authentication code

I can’t see that this shouldn’t work… So I am not sure what to do about it.

Is the time and time zone set correctly?

Thank you for the quick reply…

What device / place are you referring to for the time and time zone settings?

If on the Mac, then yes, it’s correct.

If on the HA installation, I can’t access it, so I cannot confirm. But on the Windows machine, it was correct.

The host machine and Home Assistant.

You may find some assistance here:

Okay great, thank you.

Will give it a try and get back to the thread after. :slight_smile:

@tom_l

Thank you for your help on this thread. The issue is sorted now, but I actually didn’t change anything… I switched off the VM, started it up again and then the MFA just worked…

Anyway, thank you again for your help :slight_smile:

1 Like

Thank you. I had a similar problem simply after doing a series of updates. After one of them MFA stropped working and I was locked out. Your suggestion of shutting down the VM and restarting worked for me.

1 Like

I ran into an issue where suddenly my MFA no longer worked - no idea what happened here. Unfortunately I’m running HAOS, so this thread didn’t help me. I just want to post my own solution, as this is the first thread that popped up for me.

End goal is to remove the line for your user in the auth_module.totp file.
If you still have an account available with admin access, just head over to Studio Code Server, go into the .storage folder and edit the file.
Then reboot.

If you are unable to access any admin account:

  • connect a screen and keyboard to the machine you’re running HAOS on.
  • enter the home assistant docker using docker exec -it homeassistant /bin/bash
  • then proceed same as above

You can also do this via ssh by following this guide to gain root access: Debugging the Home Assistant Operating System | Home Assistant Developer Docs

If you don’t know which one is your user, either check the user id in the people settings or, if you don’t have admin access:

  • just copy the file contents to your computer,
  • remove all the users from the file on your host machine and reboot
  • All MFA will now be removed
  • You can then go into people settings with your admin account and find out which user id belongs to which user
  • Edit the local copy of your file to remove your own user from the list
  • paste it back into the host machine and reboot