How do I fix this error when SSHing into my EC2 instance?



I'm pretty new to AWS and Linux, and I'm trying to learn, so please bear with me as I know this probably is a noob question.

I'm trying to SSH into my Linux EC2 instance on my Windows pc using cmd, and this is the error I get:

Load key "linuxmc.pem": Permission denied Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Any ideas on how I could fix this? Sorry again if it's a dumb question, but I wasn't able to find the solution after a lot of googling.


asked 2 months ago97 views
2 Answers

putty is a tool to connect linux instances from windows os. but at first you need to convert your key file for putty

first download putty and puttygen and then follow the previous link or the following to connect your linux instance by using putty

  1. Convert the .pem key to a .ppk key: You need to convert the .pem key to a .ppk key format, as it is the preferred format for Windows. You can use a tool like PuTTYgen to do the conversion. Download PuTTYgen from the official PuTTY download page: Once you have PuTTYgen, follow these steps to convert the key:

Open PuTTYgen. Click the "Load" button and select your .pem key file (linuxmc.pem). Once the key is loaded, click the "Save private key" button and save the file with a .ppk extension (for example, linuxmc.ppk).

  1. Set the correct permissions for the .ppk key file: By default, Windows doesn't have the same permission restrictions as Linux, so you usually don't need to change permissions for the .ppk file. However, if you encounter permission-related issues, you can try the following: Right-click the .ppk key file and click "Properties." Go to the "Security" tab. Ensure that only the current user has "Read" permissions and other users/groups have no access.

3.SSH into the EC2 instance using PuTTY or Windows OpenSSH: For PuTTY:

Download and install PuTTY from the official download page (same as the link mentioned above). Open PuTTY and enter the public DNS of your EC2 instance in the "Host Name (or IP address)" field. In the "Category" tree, navigate to Connection > SSH > Auth. Click the "Browse" button and select your .ppk key file (linuxmc.ppk). Go back to the "Session" category and click "Open" to start the SSH connection. For Windows OpenSSH (CMD or PowerShell):

Make sure OpenSSH is installed on your Windows system (Windows 10 build 1809 and later have it built-in). Open a CMD or PowerShell window and run the following command:

ssh -i path\to\linuxmc.ppk

Replace path\to\linuxmc.ppk with the actual path to the .ppk file.

That should resolve the issue and allow you to SSH into your EC2 instance. If you still face issues, double-check the security group settings for your instance, ensuring that it allows incoming SSH traffic (port 22) from your IP address.

profile picture
answered 2 months ago
  • Thanks a lot, this worked!

  • you are welcome



If you are trying to connect to an EC2 Linux instance using Windows, you must use the PuTTy application [0]. Following the documentation provided, you will be able to load the SSH key into PuTTy and connect from there. If the instance is question is using a Windows AMI, then you can connect using RDP [1]. Please keep in mind port 3389 must be open for inbound access in the instances security group to connect via RDP. I hope this information helps, if there are any further questions feel free to reach back out!

[0] Connect to Instance Using Windows

[1] Connect to Windows Instance Using RDP

answered 2 months ago
  • Hi

    Sorry for not mentioning it, but my instance is running Amazon Linux. Will PuTTy work with Linux? Again, sorry, I'm a total noob

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions