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

0

Hey!

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

ec2_user@ec2-3-110-105-158.ap-south-1.compute.amazonaws.com: 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.

Thanks.

iTcxic
質問済み 1年前362ビュー
2回答
4

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: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html 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 ec2-user@ec2-3-110-105-158.ap-south-1.compute.amazonaws.com

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
エキスパート
回答済み 1年前
  • Thanks a lot, this worked!

  • you are welcome

3

Hello!

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 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html

[1] Connect to Windows Instance Using RDP https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/connecting_to_windows_instance.html#connect-rdp

AWS
回答済み 1年前
  • 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

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ