Software⏱️ 2 min read📅 2026-05-31

How to Fix: Permission denied (publickey). SSH from local Ubuntu to Amazon EC2 server

SSH permission denied error on Amazon EC2 instance

Quick Answer: Check the security group settings for your EC2 instance to ensure it allows inbound SSH traffic from your local IP address.

The Permission denied (publickey) error when SSHing from a different local Ubuntu to an Amazon EC2 instance can be caused by various factors, including security settings and certificate issues. In this article, we will explore the root causes of this error and provide two methods to resolve it.

🛑 Root Causes of the Error

  • Insufficient permissions on the EC2 instance
  • Incompatible SSH keys
  • Limited IP access to the EC2 instance

🚀 How to Resolve This Issue

Method 1: Update SSH Keys

  1. Step 1: Connect to the EC2 instance and run the command `ssh-keygen -t rsa -b 2048` to generate a new SSH key pair.

Method 2: Update Security Group Settings

  1. Step 1: Connect to the EC2 instance and run the command `sudo apt-get update && sudo apt-get install -y openssh-server` to update the SSH server.

✨ Wrapping Up

By following these methods, you should be able to resolve the Permission denied (publickey) error and establish a secure SSH connection to your Amazon EC2 instance from your local Ubuntu.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions