New Key for Gitlab

Make new key

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_gitlab_ee -C "your_email@example.com"

add to gitlab

  1. Configure SSH to Use Your Specific Key

Because Git looks for default key names (like id_ed25519 or id_rsa), you must tell SSH when to use your new custom key. [1, 2]

  1. Open or create your SSH configuration file:

    bash

    nano ~/.ssh/config
    

    Use code with caution.

  2. Add the following block, replacing ://yourcompany.com with your self-hosted GitLab EE domain (or gitlab.com if using their cloud enterprise edition):

    text

    Host ://yourcompany.com
        HostName ://yourcompany.com
        User git
        IdentityFile ~/.ssh/id_ed25519_gitlab_ee
    

    Use code with caution.

  3. Save and close the file (in Nano, press Ctrl+O, Enter, then Ctrl+X).

  4. Add the Key to Your Local SSH Agent

To avoid entering your password every time, register the key with your system's ssh-agent: [1, 2]

bash

# Start the ssh-agent in the background
eval "$(ssh-agent -s)"

# Add your custom private key
ssh-add ~/.ssh/id_ed25519_gitlab_ee

Use code with caution.

  1. Add the Public Key to GitLab EE

Now, you need to copy the contents of the public key file (.pub) and add it to your profile. [1, 2]

  1. Copy the public key to your clipboard:

    • macOS: pbcopy < ~/.ssh/id_ed25519_gitlab_ee.pub
    • Linux: xclip -sel clip < ~/.ssh/id_ed25519_gitlab_ee.pub
    • Windows (Git Bash): cat ~/.ssh/id_ed25519_gitlab_ee.pub | clip [1, 2]
  2. Sign in to your GitLab EE instance. [1, 2]

  3. Click your Avatar in the top-right corner and select Preferences or Edit Profile. [1, 2, 3]

  4. On the left sidebar, click SSH Keys. [1, 2]

  5. Click Add new key, paste your public key text into the field, give it a recognizable title, and click Add key. [1, 2, 3]

  6. Verify the Connection

Test your setup by running the following command in your terminal: [1]

bash

ssh -T git@spiffydesign.com

Use code with caution.

(Replace ://yourcompany.com with your actual instance domain).

If successful, you will see a message like: Welcome to GitLab, @your_username! [1]