Two-factor authentication | GitLab (2024)

  • Use personal access tokens with two-factor authentication
  • OAuth credential helpers
    • Git Credential Manager
    • git-credential-oauth
  • Enable two-factor authentication
    • Enable one-time password
    • Enable one-time password using FortiAuthenticator
    • Enable one-time password using Cisco Duo
      • Prerequisites
      • Configure Cisco Duo in GitLab
    • Enable one-time password using FortiToken Cloud
    • Set up a WebAuthn device
  • Recovery codes
    • Regenerate two-factor authentication recovery codes
  • Sign in with two-factor authentication enabled
    • Sign in using a one-time password
    • Sign in using a WebAuthn device
  • Disable two-factor authentication
  • Information for GitLab administrators

Tier: Free, Premium, UltimateOffering: GitLab.com, Self-managed

Two-factor authentication (2FA) provides an additional level of security to your GitLab account. For others to accessyour account, they would need your username and password and access to your second factor of authentication.

GitLab supports as a second factor of authentication:

  • Time-based one-time passwords (TOTP). When enabled, GitLab promptsyou for a code when you sign in. Codes are generated by your one-time password authenticator (for example, a passwordmanager on one of your devices).
  • WebAuthn devices. You’re prompted to activate your WebAuthn device (usually by pressing a button on it) whenyou supply your username and password to sign in. This performs secure authentication on your behalf.

If you set up a device, also set up a TOTP so you can still access your account if you lose the device.

Use personal access tokens with two-factor authentication

When 2FA is enabled, you can’t use your password to authenticate with Git over HTTPS or the GitLab API.You can use a personal access token instead.

OAuth credential helpers

The following Git credential helpers authenticate to GitLab using OAuth. This is compatible with two-factor authentication. The first time you authenticate, the helper opens the web browser and GitLab asks you to authorize the app. Subsequent authentication requires no interaction.

Git Credential Manager

Git Credential Manager (GCM) authenticates by default using OAuth. GCM supports GitLab.com without any manual configuration. To use GCM with self-managed GitLab, see GitLab support.

So you do not need to re-authenticate on every push, GCM supports caching as well as a variety of platform-specific credential stores that persist between sessions. This feature is useful whether you use personal access tokens or OAuth.

Git for Windows includes Git Credential Manager.

Git Credential Manager is developed primarily by GitHub, Inc. It is an open-source project and is supported by the community.

git-credential-oauth

git-credential-oauth supports GitLab.com and several popular public hosts without any manual configuration needed. To use with self-managed GitLab, see the git-credential-oauth custom hosts documentation.

Many Linux distributions include git-credential-oauth as a package.

git-credential-oauth is an open-source project supported by the community.

Enable two-factor authentication

You can enable 2FA using a:

  • One-time password authenticator. After you enable 2FA, back up your recovery codes.
  • WebAuthn device.

Your account email must be confirmed to enable 2FA.

Enable one-time password

To enable 2FA with a one-time password:

  1. In GitLab:
    1. Access your User settings.
    2. Select Account.
    3. Select Enable Two-factor Authentication.
  2. On your device (usually your phone):
    1. Install a compatible application. For example:
    2. In the application, add a new entry in one of two ways:
      • Scan the code displayed by GitLab with your device’s camera to add the entry automatically.
      • Enter the details provided to add the entry manually.
  3. In GitLab:
    1. Enter the six-digit pin number from the entry on your device into Pin code.
    2. Enter your current password.
    3. Select Submit.

If you entered the correct pin, GitLab displays a list of recovery codes. Download them and keep themin a safe place.

Enable one-time password using FortiAuthenticator

On self-managed GitLab, by default this feature is not available. To make it available per user, an administrator canenable the feature flag named forti_authenticator.On GitLab.com and GitLab Dedicated, this feature is not available.

You can use FortiAuthenticator as a one-time password (OTP) provider in GitLab. Users must:

  • Exist in both FortiAuthenticator and GitLab with the same username.
  • Have FortiToken configured in FortiAuthenticator.

You need a username and access token for FortiAuthenticator. The access_token shown below is the FortAuthenticatoraccess key. To get the token, see the REST API Solution Guide atFortinet Document Library.Tested with FortAuthenticator version 6.2.0.

Configure FortiAuthenticator in GitLab. On your GitLab server:

  1. Open the configuration file.

    For Linux package installations:

    sudo editor /etc/gitlab/gitlab.rb

    For self-compiled installations:

  2. Add the provider configuration.

    For Linux package installations:

    gitlab_rails['forti_authenticator_enabled'] = truegitlab_rails['forti_authenticator_host'] = 'forti_authenticator.example.com'gitlab_rails['forti_authenticator_port'] = 443gitlab_rails['forti_authenticator_username'] = '<some_username>'gitlab_rails['forti_authenticator_access_token'] = 's3cr3t'

    For self-compiled installations:

    forti_authenticator: enabled: true host: forti_authenticator.example.com port: 443 username: <some_username> access_token: s3cr3t
  3. Save the configuration file.
  4. Reconfigure(Linux package installations) or restart(self-compiled installations).

Enable one-time password using Cisco Duo

History

  • Introduced in GitLab 15.10.

On self-managed GitLab, by default this feature is available. On GitLab.com this feature is not available.

You can use Cisco Duo as an OTP provider in GitLab.

DUO® is a registered trademark of Cisco Systems, Inc., and/or its affiliates in the United States and certain other countries.

Prerequisites

To use Cisco Duo as an OTP provider:

  • Your account must exist in both Cisco Duo and GitLab, with the same username in both applications.
  • You must have configured Cisco Duo and have an integration key, secret key, and API hostname.

For more information, see the Cisco Duo API documentation.

GitLab 15.10 has been tested with Cisco Duo version D261.14

Configure Cisco Duo in GitLab

On your GitLab server:

  1. Open the configuration file.

    For Linux package installations:

    sudo editor /etc/gitlab/gitlab.rb

    For self-compiled installations:

    cd /home/git/gitlabsudo -u git -H editor config/gitlab.yml
  2. Add the provider configuration.

    For Linux package installations:

     gitlab_rails['duo_auth_enabled'] = false gitlab_rails['duo_auth_integration_key'] = '<duo_integration_key_value>' gitlab_rails['duo_auth_secret_key'] = '<duo_secret_key_value>' gitlab_rails['duo_auth_hostname'] = '<duo_api_hostname>'

    For self-compiled installations:

    duo_auth: enabled: true hostname: <duo_api_hostname> integration_key: <duo_integration_key_value> secret_key: <duo_secret_key_value>
  3. Save the configuration file.
  4. For Linux package installations, reconfigure GitLab.For self-compiled installations, restart GitLab.

Enable one-time password using FortiToken Cloud

Offering: Self-managed

On self-managed GitLab, by default this feature is not available. To make it available per user, an administrator canenable the feature flag named forti_token_cloud.On GitLab.com and GitLab Dedicated, this feature is not available.This feature is not ready for production use.

You can use FortiToken Cloud as a one-time password (OTP) provider in GitLab. Users must:

  • Exist in both FortiToken Cloud and GitLab with the same username.
  • Have FortiToken configured in FortiToken Cloud.

You need a client_id and client_secret to configure FortiToken Cloud. To get these, see the REST API Guide atFortinet Document Library.

Configure FortiToken Cloud in GitLab. On your GitLab server:

  1. Open the configuration file.

    For Linux package installations:

    sudo editor /etc/gitlab/gitlab.rb

    For self-compiled installations:

    cd /home/git/gitlabsudo -u git -H editor config/gitlab.yml
  2. Add the provider configuration.

    For Linux package installations:

    gitlab_rails['forti_token_cloud_enabled'] = truegitlab_rails['forti_token_cloud_client_id'] = '<your_fortinet_cloud_client_id>'gitlab_rails['forti_token_cloud_client_secret'] = '<your_fortinet_cloud_client_secret>'

    For self-compiled installations:

    forti_token_cloud: enabled: true client_id: YOUR_FORTI_TOKEN_CLOUD_CLIENT_ID client_secret: YOUR_FORTI_TOKEN_CLOUD_CLIENT_SECRET
  3. Save the configuration file.
  4. Reconfigure (Linux package installations) orrestart (self-compiled installations).

Set up a WebAuthn device

History

  • Optional one-time password authentication for WebAuthn devices introduced in GitLab 15.10 with a flag named webauthn_without_totp. Enabled on GitLab.com and self-managed by default.

On self-managed GitLab, by default, optional one-time password authentication for WebAuthn devices is not available. To enable the feature, an administrator can enable the feature flag named webauthn_without_totp.On GitLab.com, this feature is available. On GitLab Dedicated, this feature is not available.

WebAuthn is supported by the following:

  • Desktop browsers:
    • Chrome
    • Edge
    • Firefox
    • Opera
    • Safari
  • Mobile browsers:
    • Chrome for Android
    • Firefox for Android
    • iOS Safari (since iOS 13.3)

To set up 2FA with a WebAuthn-compatible device:

  1. Optional. Set up a one-time password.
  2. Access your User settings.
  3. Select Account.
  4. Select Enable Two-Factor Authentication.
  5. Plug in your WebAuthn device.
  6. Enter a device name and in GitLab 15.10 and later, your GitLab account password.You might not need to enter this password if you have signed in through youridentity provider.
  7. Select Set up New WebAuthn Device.
  8. Depending on your device, you might have to press a button or touch a sensor.

You should receive a message indicating that you successfully set up your device.

When you set up 2FA with a WebAuthn-compatible device, that device is linked toa specific browser on a specific computer. Depending on the browser and WebAuthndevice, you might be able to configure settings to use the WebAuthn device on adifferent browser or computer.

If this is the first time you have set up 2FA, youmust download recovery codes so you can recover access to youraccount if you lose access.

You can lose access to your account if you clear your browser data.

Recovery codes

Immediately after successfully enabling 2FA with a one-time password, you’re prompted to downloada set of generated recovery codes. If you ever lose access to your one-time password authenticator, you can use one ofthese recovery codes to sign in to your account.

Each code can be used only once to sign in to your account.

You should copy and print the codes, or use Download codes to download them for storage in a safeplace. If you choose to download them, the file is called gitlab-recovery-codes.txt.

  • Recovery codes are not generated for WebAuthn devices.
  • gitlab-sshd is not suitable for regenerating recovery codes.

If you lose the recovery codes, or want to generate new ones, you can use either:

  • The 2FA account settings page.
  • SSH.

Regenerate two-factor authentication recovery codes

To regenerate 2FA recovery codes, you need access to a desktop browser:

  1. Access your User settings.
  2. Select Account > Two-Factor Authentication (2FA).
  3. If you’ve already configured 2FA, select Manage two-factor authentication.
  4. In the Disable two-factor authentication section, enter your current password in the Current password text boxand select Regenerate recovery codes.

If you regenerate 2FA recovery codes, save them. You can’t use any previously created 2FA codes.

Sign in with two-factor authentication enabled

Signing in with 2FA enabled is only slightly different than the typical sign-in process. Enter your username and passwordand you’re presented with a second prompt, depending on which type of 2FA you’ve enabled.

Sign in using a one-time password

When asked, enter the pin from your one-time password authenticator application or a recovery code to sign in.

Sign in using a WebAuthn device

In supported browsers, you should be automatically prompted to activate your WebAuthn device (for example, by touchingor pressing its button) after entering your credentials.

A message displays indicating that your device responded to the authentication request and you’re automatically signedin.

Disable two-factor authentication

To disable 2FA:

  1. Access your User settings.
  2. Select Account.
  3. Select Manage two-factor authentication.
  4. In the Disable two-factor authentication section, enter your current password in the Current password text boxand select Disable two-factor authentication.

This clears all your 2FA registrations, including mobile applications and WebAuthn devices.

Information for GitLab administrators

Tier: Free, Premium, UltimateOffering: Self-managed

  • Take care that 2FA keeps working after restoring a GitLab backup.
  • To ensure 2FA authorizes correctly with a time-based one-time password (TOTP) server, synchronize your GitLabserver’s time using a service like NTP. Otherwise, authorization can always fail because of time differences.
  • The GitLab WebAuthn implementation does not work when the GitLab instance is accessed from multiple hostnamesor FQDNs. Each WebAuthn registration is linked to the current hostname at the time of registration, andcannot be used for other hostnames or FQDNs.

    For example, if a user is trying to access a GitLab instance from first.host.xyz and second.host.xyz:

    • The user signs in by using first.host.xyz and registers their WebAuthn key.
    • The user signs out and attempts to sign in by using first.host.xyz - WebAuthn authentication succeeds.
    • The user signs out and attempts to sign in by using second.host.xyz - WebAuthn authentication fails, becausethe WebAuthn key has only been registered on first.host.xyz.
  • To enforce 2FA at the system or group levels see, Enforce two-factor authentication.
Two-factor authentication | GitLab (2024)
Top Articles
Public key cryptography: RSA keys
Can a Financial Advisor Help Make a Budget?
Is Sam's Club Plus worth it? What to know about the premium warehouse membership before you sign up
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Craigslist Niles Ohio
Wizard Build Season 28
Readyset Ochsner.org
Apex Rank Leaderboard
Elden Ring Dex/Int Build
Atrium Shift Select
Skip The Games Norfolk Virginia
Oppenheimer & Co. Inc. Buys Shares of 798,472 AST SpaceMobile, Inc. (NASDAQ:ASTS)
Elizabethtown Mesothelioma Legal Question
Missing 2023 Showtimes Near Landmark Cinemas Peoria
Sony E 18-200mm F3.5-6.3 OSS LE Review
Gino Jennings Live Stream Today
Munich residents spend the most online for food
Tamilrockers Movies 2023 Download
Katherine Croan Ewald
Diamond Piers Menards
The Ultimate Style Guide To Casual Dress Code For Women
Site : Storagealamogordo.com Easy Call
Is Windbound Multiplayer
Filthy Rich Boys (Rich Boys Of Burberry Prep #1) - C.M. Stunich [PDF] | Online Book Share
Integer Division Matlab
Sandals Travel Agent Login
Horn Rank
Ltg Speech Copy Paste
Random Bibleizer
Craigslist Fort Smith Ar Personals
The Clapping Song Lyrics by Belle Stars
Poe T4 Aisling
R/Sandiego
Kempsville Recreation Center Pool Schedule
Rogold Extension
Beaver Saddle Ark
Log in or sign up to view
A Man Called Otto Showtimes Near Amc Muncie 12
Powerspec G512
Saybyebugs At Walmart
2007 Jaguar XK Low Miles for sale - Palm Desert, CA - craigslist
Miami Vice turns 40: A look back at the iconic series
Love Words Starting with P (With Definition)
Tlc Africa Deaths 2021
Youravon Com Mi Cuenta
Nope 123Movies Full
Kushfly Promo Code
Diario Las Americas Rentas Hialeah
Game Akin To Bingo Nyt
Marion City Wide Garage Sale 2023
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 6262

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.