I have lost my Phone and do not have the recovery code for my 2FA for GitLab.
So I am locked out of my account.
What are my options?
I have lost my Phone and do not have the recovery code for my 2FA for GitLab.
So I am locked out of my account.
What are my options?
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
THEN ...
You can create a brand new list of recovery codes via ssh:
ssh git@gitlab.com 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.
nexus6's answer also applies with GitLab Self managed, using GitLab 15.9 (February 2023)
More control over your SSH connections with gitlab-sshd
gitlab-sshd
is a standalone SSH server, written in Go, that provides more insight and control than OpenSSH.
It’s lightweight and contains minimal external dependencies.If you host a self-managed instance, switching from OpenSSH to
gitlab-sshd
gives you metrics collection, detailed logging, and graceful shutdowns for SSH connections.Unlike OpenSSH, it supports the PROXY protocol and can pass on the original IP address when operated behind a proxy. This enables you to restrict SSH access by IP address when your instance is operated behind a proxy.
GitLab.com has used
gitlab-sshd
since 15.2, and 100% of the SSH traffic passes throughgitlab-sshd
.To learn more, read this blog post. To understand how to enable it refer to the documentation.
gitlab-sshd
began as a community contribution from @lorenz. Thank you very much for your contribution!See Documentation and Issue.
This includes generating new 2FA recovery codes:
$ ssh git@<hostname> 2fa_recovery_codes
Are you sure you want to generate new two-factor recovery codes?
Any existing recovery codes you saved will be invalidated. (yes/no)
yes
Your two-factor authentication recovery codes are:
...