2

I've launched a new EC2 instance with AWS using Amazon 64 bit linux (amzn-ami-2011.09.1.x86_64-ebs (ami-20506254)) and I'm having trouble ssh-ing into it. I've generated a public/private ssh keypair using ssh-keygen -t rsa and added the .pub (public) key to my key-pairs in the EC2 management console.

When I attempt to run: ssh -i ~/.ssh/aws_ec2 -v ec2-46-137-17-221.eu-west-1.compute.amazonaws.com

I get the following output:

 OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /Users/casey/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: Connecting to ec2-79-125-85-42.eu-west-1.compute.amazonaws.com [79.125.85.42] port 22. debug1: Connection established. debug1: identity file /Users/casey/.ssh/aws_ec2 type 1 debug1: identity file /Users/casey/.ssh/id_rsa type 1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.2 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'ec2-79-125-85-42.eu-west-1.compute.amazonaws.com' is known and matches the RSA host key. debug1: Found key in /Users/casey/.ssh/known_hosts:8 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /Users/casey/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Offering public key: /Users/casey/.ssh/aws_ec2 debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). 

Not sure what's going on since it does offer my ssh private key but appears to just get denied. Anyone know what's going on?

2 Answers 2

4

I figured it out:

ssh -i ~/.ssh/aws_ec2 -v [email protected]

You need to use ec2-user as the username.

1
  • Since the title does not specify Unix flavor, I'll let the people who come here with an UBUNTU AMI need to use: "ssh -i ~/.ssh/aws_ec2 -v ubuntu@your-instance-ip" Commented Mar 23, 2015 at 21:31
0
chmod 700 /Users/casey/.ssh chmod 600 /Users/casey/.ssh/* 

Make sure you are logging in with correct username. Default ssh users provided by aws are

ec2-user : RHEL/centos, etc.. ubuntu: Ubuntu 

Also, try specifying particular key file like below.

ssh -i /Users/casey/.ssh/privatekey [email protected] 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.