Software⏱️ 4 min read📅 2026-06-11

How to Fix: Connection blocked because server only allows public key authentication [PuTTY Fatal Error]

PuTTY connection error due to server public key authentication requirement.

Quick Answer: Check if the EC2 instance has a public key file available for download and use it with PuTTY.

The error 'Connection blocked because server only allows public key authentication' occurs when the remote server, in this case an EC2 instance, is configured to only accept public key authentication. This means that the server does not allow username/password combinations or other forms of authentication besides public key authentication. This issue affects anyone trying to connect to the server using PuTTY and Windows 10.

This error can be frustrating because it prevents users from accessing their remote servers, which can lead to lost productivity and time wasted on troubleshooting. However, by following the steps outlined in this guide, you should be able to resolve the issue and regain access to your EC2 instance.

🛑 Root Causes of the Error

  • The primary reason for this error is that the EC2 instance is configured to only allow public key authentication. This can be set during the creation of the instance or through subsequent configuration. The server may also have specific requirements for the format and content of the public key file used for authentication.
  • Another possible cause could be a misconfigured PuTTY connection settings, where the private key file is not properly loaded into Pageant.

✅ Best Solutions to Fix It

Configuring Public Key Authentication on EC2 Instance

  1. Step 1: Step 1: Connect to your EC2 instance using SSH and run the following command to check the authentication settings: `sudo cat /etc/ssh/sshd_config` This will show you the current configuration of the SSH server. Look for the lines that specify the allowed authentication methods, such as `PubkeyAuthentication yes` or `PasswordAuthentication no`.
  2. Step 2: Step 2: If the instance is configured to only allow public key authentication, you may need to update the configuration file to allow other forms of authentication. For example, if you want to allow username/password combinations, uncomment the line `PasswordAuthentication yes` and comment out the line `PubkeyAuthentication yes`. Then, restart the SSH service: `sudo systemctl restart sshd`.
  3. Step 3: Step 3: Update your PuTTY connection settings to use the public key file. Open PuTTY, go to Connection > SSH > Auth, and select 'Private Key File' as the authentication method. Load the public key file into Pageant by clicking on the 'Browse' button and selecting the private key file. Then, click 'OK' to save the changes.

Alternative Method: Generating a New Public Key Pair

  1. Step 1: Step 1: Generate a new public key pair using PuTTYgen. Open PuTTYgen, go to Generation > Generate, and select 'RSA' as the algorithm. Click 'Generate' and save the resulting private key file to a secure location.
  2. Step 2: Step 2: Load the new public key file into Pageant by clicking on the 'Browse' button and selecting the private key file. Then, click 'OK' to save the changes.

🎯 Final Words

By following these steps, you should be able to resolve the issue of connection blocked because server only allows public key authentication. Remember to check your EC2 instance's configuration settings and update your PuTTY connection settings accordingly. If you are still having issues, consult with your network administrator or seek further assistance from AWS support.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions