Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

I figured it out:

ssh -i ~/.ssh/aws_ec2 -v ec2-user@ec2-79-125-85-42.eu-west-1.compute.amazonaws.com

You need to use ec2-user as the username.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.