Error Codes Wiki

Linux SSH Permission Denied (publickey) Fix

Warninglinux network

Overview

Fix "Permission denied (publickey)" SSH error. Authentication is failing with your SSH key.

Key Details

  • Error: Permission denied (publickey)
  • Category: Linux Network/SSH Error
  • SSH key authentication failed
  • Cannot log into remote server

Common Causes

  • SSH key not added to remote authorized_keys
  • Wrong key being used (multiple keys)
  • Incorrect permissions on .ssh directory
  • SSH agent not running or key not loaded

Steps

  1. 1Check key is loaded: ssh-add -l
  2. 2Add key: ssh-add ~/.ssh/id_rsa
  3. 3Verify permissions: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
  4. 4Specify key: ssh -i ~/.ssh/mykey user@host
  5. 5Check server /var/log/auth.log for details

Tags

linuxlinux-networklinux ssh permission deniedubuntuterminal

More in Linux Network

Frequently Asked Questions

~/.ssh/ must be 700, authorized_keys must be 600, private key must be 600.