1

I lost my phone which have the Authenticator app and the recovery codes, I have ssh setup on my account so I'm trying to generate new codes using ssh:

ssh git@gitlab.com 2fa_recovery_codes

this command is giving me this current output:

An error occurred while trying to generate new recovery codes.
Two-factor authentication is not enabled for this user

My account for sure have 2fa enabled on my account enter image description here Note: on my PC I have multiple gitlab accounts with ssh setup but only on have 2fa (which is the on I'm trying to recover) could this output means its generating code for the wrong gitlab account? and if so how can I generate the code for the account (the one with 2fa)?

1 Answers1

3

Check first what ssh -T git@gitlab.com returns:

Welcome to GitLab, @username! 

Make sure the username is indeed the right account (where 2FA was supposedly activated), and not another account.

With the right account, the new recovery codes using SSH generation should work.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank u for your help, is there a way to switch between accounts if its not the right username? – Maya Hamdan Oct 08 '22 at 11:12
  • @MayaHamdan Yes, you need to reference the private SSH key of the account you want to switch to in a `~/.ssh/config` file, as I [mentioned here](https://stackoverflow.com/a/73876716/6309). – VonC Oct 08 '22 at 11:25