AWS Logo
Menu
Resolve SSH require password when using key from local

Resolve SSH require password when using key from local

This error happens when you try to SSH into an EC2 instance with a key, but the server require password to login. It’s caused by PasswordAuthentication yes in the SSH config. This guide shows how to fix it by enabling key-based access and disabling password authentication.

Published Apr 15, 2025

🔧 Step 1: Disable Password Authentication on EC2

Connect to EC2 instance by using Instance Connect to bypass for password authentication.
EC2 Instance Connect
EC2 Instance Connect
  1. Switch to the root user.
  1. Open the SSH configuration file.
  1. Find the line PasswordAuthentication yes and change to PasswordAuthentication no
  2. Save the file and restart the SSH service.

🔧 Step 2: Generate a New SSH Key Pair

  1. From your local machine, run following command.
  1. Copy public key, and note that key so that we will pass that key to remote EC2 instance.
  1. On the EC2 instance, paste the public key into the ~/.ssh/authorized_keys file for the desired user.

🔧 3. SSH to your VM

Now, SSH into your EC2 instance using your private key.

🚀 BE HAPPY ON CLOUD 🚀
 

Comments