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 am unable to login to the EC2 server.

Here's the log of the connection-attempt:

$ ssh -v -i ec2-key-incoleg-x002.pem ubuntu@ec2-50-16-0-207.compute-1.amazonaws.com
OpenSSH_5.6p1, OpenSSL 0.9.8p 16 Nov 2010
debug1: Reading configuration data /home/gvaish/.ssh/config
debug1: Applying options for *
debug1: Connecting to ec2-50-16-0-207.compute-1.amazonaws.com [50.16.0.207] port 22.
debug1: Connection established.
debug1: identity file ec2-key-incoleg-x002.pem type -1
debug1: identity file ec2-key-incoleg-x002.pem-cert type -1
debug1: identity file /home/gvaish/.ssh/id_rsa type -1
debug1: identity file /home/gvaish/.ssh/id_rsa-cert 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.6
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-50-16-0-207.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/gvaish/.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: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: ec2-key-incoleg-x002.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/gvaish/.ssh/id_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).

What can be the possible reason? How do I fix the issue?

share|improve this question

migrated from stackoverflow.com Mar 3 '11 at 3:24

This question came from our site for professional and enthusiast programmers.

    
I think i've found the problem... it's the username problem. What's the default user created for the AMI ami-74f0061d (It's Amazon AMI) that I'm using for a test micro instance. –  MasterGaurav Mar 3 '11 at 16:58
    
Got it. It's ec2-user –  MasterGaurav Mar 3 '11 at 17:18

1 Answer 1

It looks like you're using the wrong public key. Are you sure you have the right public key or that your private key on the server accepts the public key you're using?

Each EC2 instance requires the correct pem and log in user for the AMI you're using. Additionally, the AMI's don't allow remote root logins by default. The only user that should be able to log in remotely is ec2-user. For Ubuntu the default user is ubuntu. Some other AMI's like CentOS will allow you to log in as root.

share|improve this answer
    
I don't have public key under control. It's a new key that I've created on Amazon EC2. How do I associate a public/private key with an AMI instance that I've launched? –  MasterGaurav Mar 3 '11 at 16:26
2  
Once an instance is launched you cannot associate a new key. –  Flashman Apr 5 '11 at 20:30
    
If it's an EBS-backed instance you can add your own keys to it normally, just like any other remote server. For an S3 based instance, you would have to create your own AMI containing the keys you want. –  Michael Hampton Aug 13 '12 at 22:04
    
@aaron - you were right on it, why don't you edit your answer to document that EC2 instances require the correct pem file AND login user for the AMI in order to connect. Might also mention that the Amazon AMIs require ec2-user, CentOS AMIs require root, and Ubuntu require ubuntu. Then we can lock this one up. –  khoxsey Aug 13 '12 at 22:45
    
@khoxsey Thanks, will do! –  Aaron Aug 14 '12 at 13:06

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.