I know this is an old question, but the following, which I have tested only with gitlab.com free hosted accounts, may be useful for others with GitLab 2fa problems.
IF
- you have set up 2fa but then lost access to your 2fa device for some reason, and
- you have lost (or never saved) your recovery codes, and
- you had previously configured your ssh key in your gitlab.com account
THEN …
You can create a brand new list of recovery codes via ssh:
ssh [email protected] 2fa_recovery_codes
Answer the questions and save the list of recovery codes somewhere safe this time! I’m guilty of all of the above and this solution provided by GitLab is both simple and elegant.
Source: https://gitlab.com/gitlab-org/gitlab-ce/issues/3765