Troubleshooting SSH
This guide covers common SSH connection problems when you work with GitLab at LNU.
Quick verification
Section titled “Quick verification”Test your SSH connection with:
ssh -T git@gitlab.lnu.seA successful response shows: Welcome to Gitlab, @en999zz!
Network considerations
Section titled “Network considerations”The “LNU Guest” network doesn’t support SSH. Switch to “Eduroam” instead.
Diagnostic commands
Section titled “Diagnostic commands”Some commands that help you identify problems:
ssh-add -l— lists active SSH keysssh-agent— verifies whether the agent is runningls ~/.ssh/— lists stored SSH keysssh-add ~/.ssh/id_ed25519_gitlab_lnu— loads a key into the agent
Common “Permission denied” problems
Section titled “Common “Permission denied” problems”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:
Get-Service ssh-agent | Set-Service -StartupType AutomaticStart-Service ssh-agentPoint 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_lnuThe 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.
Store the key in the system keychain, so it’s loaded automatically every time you log in, without you having to enter the passphrase again:
ssh-add --apple-use-keychain ~/.ssh/id_ed25519_gitlab_lnuAlso add UseKeychain yes under the host entry for gitlab.lnu.se in ~/.ssh/config (see
Set up Git).
Most desktop environments (GNOME, KDE) handle this automatically through a built-in keyring. If it
doesn’t happen automatically for you, add the following to ~/.bashrc so the agent starts and the
key is loaded automatically in every new terminal window:
if [ -z "$SSH_AUTH_SOCK" ]; then eval $(ssh-agent -s) > /dev/null ssh-add ~/.ssh/id_ed25519_gitlab_lnu 2> /dev/nullfiThe 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_lnuIf 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.