Amazon AWS EC2 Instance - Can't connect with S

2020-07-07 11:58发布

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.

7条回答
Luminary・发光体
2楼-- · 2020-07-07 12:08

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.

查看更多
forever°为你锁心
3楼-- · 2020-07-07 12:18

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

查看更多
不美不萌又怎样
4楼-- · 2020-07-07 12:22

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

ssh -i the-keypair-filename root@yourdomain.com

- 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.

查看更多
等我变得足够好
5楼-- · 2020-07-07 12:26

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

查看更多
甜甜的少女心
6楼-- · 2020-07-07 12:26

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

查看更多
再贱就再见
7楼-- · 2020-07-07 12:28

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

查看更多
登录 后发表回答