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.
git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
# 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?
Related Developer Error Solutions
Browse All 35 GuidesGit: Refusing to merge unrelated histories
Merge repositories initialized independently with different initial commits using --allow-unrelated-histories.
AWS S3: Access Denied (403 Forbidden)
Resolve S3 authorization rejections caused by IAM permissions, bucket policies, KMS encryption, or Block Public Access.
Systemd: Start request repeated too quickly
Diagnose failing Linux systemd background services hit by StartLimitBurst protections.