GitLab Permission Denied (publickey) Error
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. Test the connection and read the debug output
- Run ssh -Tv git@gitlab.com (use your instance host if self-managed).
- Look for "Offering public key" lines to see which key SSH tries, and whether any is accepted.
- A success shows "Welcome to GitLab, @username!".
Did this fix it?2. Add your public key to GitLab
- Print the key: cat ~/.ssh/id_ed25519.pub (generate one with ssh-keygen -t ed25519 -C "you@example.com" if missing).
- In GitLab open your avatar > Preferences > SSH Keys > Add new key.
- Paste the whole .pub line and save.
Did this fix it?3. Tell SSH which key to use
- Add a block to ~/.ssh/config: Host gitlab.com, IdentityFile ~/.ssh/id_ed25519, IdentitiesOnly yes.
- Retest with ssh -T git@gitlab.com.
Did this fix it?4. Load the key into ssh-agent
- Run eval "$(ssh-agent -s)" then ssh-add ~/.ssh/id_ed25519.
- On macOS add UseKeychain yes and AddKeysToAgent yes to the config so it survives reboots.
Did this fix it?5. Fix file permissions
- chmod 700 ~/.ssh
- chmod 600 ~/.ssh/id_ed25519
- On Windows use Git Bash or OpenSSH in the same user profile.
Did this fix it?6. Use HTTPS with a token if SSH is blocked
- Create a personal access token with write_repository scope.
- 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 usThe same problem in other apps
Other GitLab errors
- GitLab Pipeline Stuck on Pending
- GitLab Runner Not Picking Up Jobs
- GitLab "HTTP Basic: Access Denied" on Push or Clone
- GitLab "You Are Not Allowed to Push Code to Protected Branches"
- How to Resolve GitLab Merge Conflicts
- GitLab "No More Compute Minutes" or CI Minutes Quota Exceeded
- GitLab Pipeline Not Running or "yaml invalid"
- Why Is GitLab So Slow?