← Back to Error Index
root@linuxfix:~/permission_denied_publickey$
permission denied publickey
Permission denied publickey SSH authentication failed

Solutions

Prerequisites: Start by updating your system to resolve common issues and ensure the solutions provided below are compatible with your current environment.
check_latest_version && sudo apt update && sudo apt upgrade -y
Check SSH key

Verify correct key is used:

ssh-add -l
ssh -i ~/.ssh/id_rsa user@host
cat ~/.ssh/id_rsa.pub
Fix permissions

Set correct file permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
Add key to agent

Load key into SSH agent:

eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa
ssh-add -l

What is permission denied publickey?

SSH key authentication failed due to incorrect keys, permissions, or configuration.

Common scenarios: Wrong SSH keys, incorrect permissions, agent not running, or server misconfiguration.

Common Causes

  • Wrong SSH key
  • Incorrect file permissions
  • SSH agent not running
  • Key not added to agent
  • Server configuration

Debugging Tips

ssh -vvv user@host
ls -la ~/.ssh/
cat ~/.ssh/config

Prevention

  • Backup SSH keys
  • Set correct permissions
  • Use SSH agent
  • Test key authentication
ssh authentication publickey permissions