Error Codes Wiki

Linux SSH Permission Denied (publickey) Fix

Warninglinux network

About Linux SSH Permission Denied (publickey) Fix

Fix "Permission denied (publickey)" SSH error. Authentication is failing with your SSH key. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: Error: Permission denied (publickey). Category: Linux Network/SSH Error. SSH key authentication failed. Cannot log into remote server. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: 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. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check key is loaded: ssh-add -l. Add key: ssh-add ~/.ssh/id_rsa. Verify permissions: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys. Specify key: ssh -i ~/.ssh/mykey user@host. Check server /var/log/auth.log for details. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

What permissions does .ssh need?

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

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.