Geek Stocks
Geek Stocks

Reputation: 2030

Amazon AWS EC2 Instance - Can't connect with SSH

This shouldn't be this hard. I cannot connect to new AWS EC2 instance via SSH clients. I am connecting from a Win 7 box.

Instance OS: Debian 6

AMI: debian-squeeze-i386-20121119-e4554303-3a9d-412e-9604-eae67dde7b76-ami-1977f070.1(ami-a121a6c8)

User: tried root and also ec2-user

Using .pem keypair that AWS generated and I downloaded

Confirmed security group and Key Pair Name on instance

SSH port 22 is OPEN: Nmap says so and Telnet gets a welcome reply

Using 3 different clients: all clients connect ok

PuTTY replies: Server refused our key

MindTerm Java browser add-in replies: Authentication failed, permission denied

Bitvise SSH replies: Attempting 'publickey' auth; auth failed;

Rebooted instance, wash, rinse, repeat...

REBUILT new instance and new keypair, wash, rinse, repeat...

Connecting isn't the issue. Why would the instance not accept the .pem file as the password? Is there an additional step I am missing? I followed EVERY frigging guide I could Google. AWS support is a joke. stackoverflow to the rescue...

TIA.

Upvotes: 9

Views: 24336

Answers (7)

Erin
Erin

Reputation: 1

Logging in as "ubuntu" worked for me:

ssh -i private_key.pem ubuntu@myubuntuserver

Hope this helps

--Erin

Upvotes: -3

Ed Lenox
Ed Lenox

Reputation: 11

My problem was that I didn't add a volume that was expected in the fstab file so the server didn't start fully and the sshd daemon wasn't running.

Check with:

    telnet HOST 22

Check the server logs to make sure it starts properly before you waste lots of time like I did.

Upvotes: 1

Chandan Patra
Chandan Patra

Reputation: 491

I had the similar problem and I have solved the issue by following approach.

1) Edited the knife.rb file in my chef folder i.e. :\Users\Administrator\chef-starter\chef-repo.chef\knife.rb as bellow:

knife[:aws_access_key_id]     = "xxxxxxxxxxxxxxxxxxxx"
knife[:aws_secret_access_key] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
knife[:region]                = 'ap-southeast-1'
knife[:aws_ssh_key_id] = "ChefUser"
knife[:ssh_user]="ec2-user"

In the command prompt, issued the command to create an ec2-server:

knife ec2 server create -r "role[webserver]" --image ami-abcd1234 --flavor t1.micro -G  ChefClient -x root -N server01 -i H:\Chef-files\ChefUser.pem

Note that, even though I had given all the details in the knife.rb file, I had to give the .pem file path in coomand line through -i option. That solved my problem.

Check, if the solution of mine helps you.

Cheers,

Chandan

Upvotes: 0

georger
georger

Reputation: 1668

Try using the "admin" username and ignore the username suggested by Amazon.

Upvotes: 1

Teri
Teri

Reputation: 1

Amazon Linux AMIs that use ec2-user password are listed at the bottom of this page.

http://aws.amazon.com/amazon-linux-ami/

Check that you are using one of those if trying to use ec2-user, or check the documentation for the AMI you are using.

Teri

Upvotes: 0

datasage
datasage

Reputation: 19563

According to the debian wiki which has documentation on the AMI you are using, the username you need to use to login is 'admin'.

Upvotes: 15

CoderDan
CoderDan

Reputation: 462

I have had many issues with connecting to EC2 via ssh.

ssh -i the-keypair-filename [email protected]

- Keypair file must be in same directory. - I just used terminal to connect.

Make sure you generate or assign the keypair when launching the instance.

Also you can verify the keypair you have set in the AWS Management Console, this is done by selecting the running instance and then looking for "Key Pair Name:".

I hope this is helpful.

Upvotes: 1

Related Questions