Skip to content

Troubleshooting SSH

This guide covers common SSH connection problems when you work with GitLab at LNU.

Test your SSH connection with:

ssh -T git@gitlab.lnu.se

A successful response shows: Welcome to Gitlab, @en999zz!

The “LNU Guest” network doesn’t support SSH. Switch to “Eduroam” instead.

Some commands that help you identify problems:

  • ssh-add -l — lists active SSH keys
  • ssh-agent — verifies whether the agent is running
  • ls ~/.ssh/ — lists stored SSH keys
  • ssh-add ~/.ssh/id_ed25519_gitlab_lnu — loads a key into the agent

The error git@gitlab.lnu.se: Permission denied (publickey) is usually caused by one of three things:

Wrong SSH key

Compare your local fingerprint (ssh-add -l) with the one stored on GitLab under your account settings. They must match.

The SSH agent isn’t running

If ssh-add -l returns "Could not open a connection to your authentication agent", start the agent:

eval $(ssh-agent -s)

How to avoid having to redo this every time differs between operating systems:

Windows has a built-in ssh-agent service that keeps added keys permanently, even after a restart — but it’s disabled by default. On top of that, Git Bash by default talks to its own bundled SSH client instead of Windows’ own, so git push/git pull would never reach that service unless Git is pointed elsewhere. Three one-time steps fix both.

Enable the service in PowerShell as administrator:

Terminal window
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent

Point Git at Windows’ own SSH client, so that git push/git pull actually talk to the same agent:

git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"

Load the key into the Windows agent — give the full path to ssh-add.exe, otherwise Git Bash finds its own bundled variant instead of Windows’ own:

/c/Windows/System32/OpenSSH/ssh-add.exe ~/.ssh/id_ed25519_gitlab_lnu

The key now stays in the agent permanently, even after restarting the computer — you never need to run ssh-add again, whether or not you have a Git Bash window open.

The key isn’t loaded

If ssh-add -l shows "The agent has no identities", the agent is running but doesn’t have your key. Load it manually:

ssh-add ~/.ssh/id_ed25519_gitlab_lnu

If you’d rather not depend on the agent at all, edit ~/.ssh/config and add an IdentityFile line under the host entry for gitlab.lnu.se (see Set up Git) — SSH then uses the key directly without an agent having to load it.

CCBY