GitLab Permission Denied (publickey) Error

Share
Workaround available Windows, macOS, Linux Updated November 13, 2026Based on 3 user reportsHow we research

Quick answer

GitLab cannot match the key your SSH client offers to a public key on your account. Add the right public key in Preferences > SSH Keys and make SSH offer that key.

Most likely fix: Test the connection and read the debug output

How to fix it

Try these in order — the most common fix is first.

  1. 1. Test the connection and read the debug output

    1. Run ssh -Tv git@gitlab.com (use your instance host if self-managed).
    2. Look for "Offering public key" lines to see which key SSH tries, and whether any is accepted.
    3. A success shows "Welcome to GitLab, @username!".
    Did this fix it?
  2. 2. Add your public key to GitLab

    1. Print the key: cat ~/.ssh/id_ed25519.pub (generate one with ssh-keygen -t ed25519 -C "you@example.com" if missing).
    2. In GitLab open your avatar > Preferences > SSH Keys > Add new key.
    3. Paste the whole .pub line and save.
    Did this fix it?
  3. 3. Tell SSH which key to use

    1. Add a block to ~/.ssh/config: Host gitlab.com, IdentityFile ~/.ssh/id_ed25519, IdentitiesOnly yes.
    2. Retest with ssh -T git@gitlab.com.
    Did this fix it?
  4. 4. Load the key into ssh-agent

    1. Run eval "$(ssh-agent -s)" then ssh-add ~/.ssh/id_ed25519.
    2. On macOS add UseKeychain yes and AddKeysToAgent yes to the config so it survives reboots.
    Did this fix it?
  5. 5. Fix file permissions

    1. chmod 700 ~/.ssh
    2. chmod 600 ~/.ssh/id_ed25519
    3. On Windows use Git Bash or OpenSSH in the same user profile.
    Did this fix it?
  6. 6. Use HTTPS with a token if SSH is blocked

    1. Create a personal access token with write_repository scope.
    2. git remote set-url origin https://gitlab.com/<group>/<project>.git and use the token as the password.
    Did this fix it?

Symptoms

git clone, pull or push over SSH fails with "git@gitlab.com: Permission denied (publickey)" or "Could not read from remote repository".

Why it happens

  • Public key not added to your GitLab profile
  • SSH offers a different private key than the one you added
  • Key not loaded in ssh-agent (common after reboot)
  • Private key file permissions too open (not 600) or .ssh not 700
  • Unsupported key type or a corrupted key paste

This guide also covers

  • gitlab permission denied publickey
  • git@gitlab.com permission denied (publickey)
  • gitlab ssh key not working
  • could not read from remote repository gitlab

Still not working?

If GitLab keeps failing, you're not alone. See every GitLab problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other GitLab errors

All 11 GitLab errors and fixes →