Stupidly Deleted "twofactor_backupcodes", How Do I Get Them Back?

Nextcloud version: 20.0.6
Apache: 2.4.38
PHP version: 7.4
.
.
Recently, I lost access to my twofactor apps and backup codes all at once.
But that’s not the problem, after pouring though the forums, I managed to disable twofactorauth, login to my account, and reinstall and setup the app.

But while looking for solutions, I had honestly no idea what I was doing and deleted all 3 folders of
twofactor_totp
twofactor_nextcloud_notification
twofactor_backupcodes
from the apps folder in /var/www/nextcloud/apps

As the initial 2 are apps, reinstalling them has managed to fix any rookie mistake I made.
But the backup codes… they’re not an app, I can’t seem to find them anywhere.
Thus I have no option to generate backup codes for my account.

./occ twofactorauth:state Admin gives me:

Enabled providers:

  • totp
  • twofactor_nextcloud_notification

./occ app:enable twofactor_backupcodes gives me:

twofactor_backupcodes already enabled
… Even though I can’t find it in the app list anymore

This is quite important as I would need them should I lose access to my apps again, does anybody know how I can get them back?

if the app is not listed anymore but counts as installed in the database a cycle of uninstall/install should fix the problem. Once the apps are functional you can generate new backup codes again (I’m not sure if this invalidates previously created - I would expect this).

Ahh I’ve tried this, but unfortunately I always get an Error.

sudo -u www-data php occ app:install twofactor_backupcodes gives:
Error: Could not download app twofactor_backupcodes

I thought this was just a problem on my end, but I can install any other app just fine.

sudo -u www-data php occ app:disable twofactor_backupcodes gives:
twofactor_backupcodes can’t be disabled.

sudo -u www-data php occ app:remove twofactor_backupcodes gives:
twofactor_backupcodes is not installed

1 Like

Download the app archive manually, extract its content to the correct app folder, set the correct access rights, enable the app - that should do the job.

1 Like

Thanks for the idea, I managed to find an archive here.

I can set permissions and whatnot, but the webpage says
The files of the app Two factor backup codes (twofactor_backupcodes) were not replaced correctly. Make sure it is a version compatible with the server.

Currently my versions are:

  • twofactor_backupcodes: 1.9.0
  • twofactor_nextcloud_notification: 3.1.2
  • twofactor_totp: 5.0.0

How do I know what would be the correct version, and more importantly, where would I find it?

Ahh nevermind I figured it out, all that had to be done was change tag in branch to match my nextcloud version.
I assume the app will be updated as normal when I upgarde now?

Thanks for the help!

1 Like