DoIT Shared Tools - GitLab - Setting up remote repositories

Recommended methods for connecting to a remote GitLab repository

GitLab projects frequently serve as the shared version-control source for many users collaborating on the same project. Users can keep their work synchronized by adding the shared GitLab project as a remote for their local Git project repositories. The following two authentication methods can be used for connecting to remote GitLab projects. 

Benefits/Restrictions

Token-based authentication allows you to define the token's scope of actions, which is a helpful security measure. 

In addition, token-based authentication uses the HTTPS port like most web traffic, unlike SSH access which requires opening an additional port to a large number of users. 

As a result, you are allowed to authenticate with your token from an off-campus IP address. This flexibility can be especially important if you want, for example, to clone a remote GitLab repository into your cloud account with Amazon Web Services, Google Cloud or Microsoft Azure. 

Token-based Authentication (recommended) 

  • Create a Personal Access Token (PAT) in your GitLab account.

    For GitLab HTTPS operations, the token should include one of the following scopes:

    • api (recommended)
    • read_repository (clone and fetch only)
    • write_repository (required for push operations)

  • Copy the token to a temporary location.

  • Clone the repository using the HTTPS URL.

    When prompted for credentials: Username: Your GitLab username Password: Your Personal Access Token

    Shell example:
    git clone https://git.doit.wisc.edu/group/project.git

  • Configure Git credential storage to save the token on your workstation for future authentication to https://git.doit.wisc.edu.

    Recommended: Integrate Git credentials with your operating system's secure credential manager (for example, macOS Keychain Access or Windows Credential Manager). This prevents the token from being stored in plain text.

    Alternative: Store the token in a plain-text .git-credentials file:

    Plain text example:
    https://<your username>:<personal access token> git.doit.wisc.edu

  • Delete the token from the temporary location.
  • Use HTTPS URLs whenever you clone a GitLab project to your workstation or add a GitLab project as a remote for a local repository.

SSH key-based Authentication

Benefits/Restrictions

You can only connect via SSH to a project in DoIT's GitLab instance from an on-campus IP address. Users working off-campus must log into the WiscVPN (WiscVPN - Overview) before they can connect with SSH.

Set up SSH key-based Authentication

    1. Follow GitLab's instructions for setting up your SSH key.
    2. Use the SSH URL whenever you clone a GitLab project to your workstation and whenever you add a GitLab project as a remote for a local git repository.

SSH URL for GitLab Project

Password-based Command Line Authentication (deprecated)

You can use your GitLab-specific password (not NetID password) to authenticate via the command line. This authentication method is discouraged, because it is a less secure practice and the industry standard is to stop using it. At some point in the future, this feature will be disabled, so it's best to switch to another method now. 



Keywords:
gitlab token ssh key credential wiscvpn vpn firewall git repo local authentication project security personal access token pat 
Doc ID:
117615
Owned by:
Benjamin S. in Shared Tools
Created:
2022-03-25
Updated:
2026-12-04
Sites:
DoIT Help Desk, DoIT Staff, Shared Tools