Skip to main content
Cloud & Security · Developer Error Resolution Lab

Fix SSH 'Permission denied (publickey,gssapi-keyex,gssapi-with-mic)' Error

Resolve SSH authentication failures caused by wrong file permissions, missing keys, or SSH agent issues.

Triggered Error Message:

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Customize Solution for Your Environment
# 1. Fix strict directory and file permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub

# 2. Start SSH Agent and add private key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# 3. Test GitHub / Server SSH connectivity:
ssh -Tv git@github.com

Root Cause & Mechanism Analysis

Why does this error occur?

SSH server rejected connection because the matching private key is not loaded in `ssh-agent`, the public key is not registered in `~/.ssh/authorized_keys`, or file permissions on `~/.ssh` or private keys are too permissive.

Frequently Asked Questions

Why is ED25519 recommended over RSA?
ED25519 keys are faster, provide stronger cryptographic security, and have much shorter key lengths than 4096-bit RSA keys.
Browse All 35 Guides