Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH to Amazon EC2 instance using PuTTY in Windows

I am a newbie to Amazon web services, was trying to launch an Amazon instance and SSH to it using putty from windows. These are the steps I followed:

  1. Created a key pair.

  2. Added a security group rule for SSH and HTTP.

  3. Launched and instance of EC2 using the above key pair and security group.

  4. Using PuTTYgen converted the *.pem file to *.ppk

  5. Using putty tried connecting to the public DNS of the instance and provided the *.ppk file.

I logged in using 'root' and 'ec2-user', and created the PPK file using SSH1 and SSH2, for all these attempts I get the following error in putty,

"Server refused our key"

Can you guys please help, any suggestions would be greatly appreciated.

like image 476
konkani Avatar asked Apr 23 '12 19:04

konkani


People also ask

How do I connect to Amazon EC2 via SSH?

To connect from the Amazon EC2 consoleOpen the Amazon EC2 console. In the left navigation pane, choose Instances and select the instance to which to connect. Choose Connect. On the Connect To Your Instance page, choose EC2 Instance Connect (browser-based SSH connection), Connect.


3 Answers

I assume that the OP figured this out or otherwise moved on, but the answer is to use ubuntu as the user (if the server is ubuntu).

like image 144
mikeabout Avatar answered Oct 07 '22 09:10

mikeabout


1) Make sure you have port 22 (SSH) opened in Security Group of EC2 Instance.

2) Try connecting with Elastic IP instead of public DNS name.

I hope you have followed these steps Connecting EC2 from a Windows Machine Using PuTTY

like image 23
shashankaholic Avatar answered Oct 07 '22 09:10

shashankaholic


Another situation where I got the "Server refused our key" error when using putty, from windows, to ssh to an EC2 instance running ubuntu:

The private key was wrongly converted from .pem to .ppk.

puttygen has two options for "converting keys".

  1. Load your .pem file into puttygen using the File->Load Private Key option and then save as .ppk file using the Save Private Key Button.
  2. DO NOT use the menu option Conversions->Import Key to load the .pem file generated by EC2.

    See the puttygen screenshots below, with the two menu options marked.

Correct menu option with puttygen Wring menu option with puttygen

like image 23
prajod Avatar answered Oct 07 '22 10:10

prajod