← Back to all fixes
SSH: Permission denied (publickey)
The Issue
`ssh user@host` returns: `Permission denied (publickey,gssapi-keyex,gssapi-with-mic)`
Root Cause
SSH key not added to authorized_keys, wrong permissions on .ssh directory, or sshd not accepting the key type.
How to Fix
Check .ssh directory permissions on the server: `chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys`Verify your public key is in authorized_keys: `cat ~/.ssh/authorized_keys`Add your key: `ssh-copy-id -i ~/.ssh/id_rsa.pub user@host`Check sshd config allows pubkey: `grep PubkeyAuthentication /etc/ssh/sshd_config` should be `yes`Debug with verbose mode: `ssh -vvv user@host` and look at which keys are tried