3

I am trying to login to instance on amazon using, my ".pem" file has 600 privileges:

ssh -v -i FTPServer.pem ec2-user@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com

i tried all possible users "root/ubuntu/ec2-user.." i always receive the following:

    OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com [xx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file FTPServer.pem type -1
debug1: identity file FTPServer.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-8
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 pat OpenSSH_5* compat 0x0c000000
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<3072<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: Server host key: RSA 0f:ad:a5:01:e1:75:82:fa:54:bd:56:53:34:d9:7e:6b
debug1: Host 'ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/myhome/.ssh/known_hosts:6
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: Offering RSA public key: Downloads/FTPServer.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: FTPServer.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
  • Have you placed the public key on the server? – Uwe Plonus May 12 '15 at 12:53
  • @UwePlonus if he's on Amazon EC2 they place the security key there for the 'ubuntu' user on Ubuntu EC2 instances upon creation... – Thomas Ward May 12 '15 at 12:57
2

Unless you provided a custom list of users upon creation, the default 'ubuntu' user should still exist, and the EC2 key was put on that user, as a typical configuration would get.

To make it work on other users, you need to take the lines from /home/ubuntu/.ssh/authorized_keys and put them into the file /home/$USER/.ssh/authorized_keys (where $USER is the username you are specifically trying to make work with that key).

Based on your comments, though, this isn't your EC2 instance, and you were just given the .pem without actual login instructions. You need to reach out to the administrator (the person who set up the EC2 instance) and request login instructions, as well as instruct them to verify that the public key for the .pem is available in the .ssh/authorized_keys file in the home directory for the user they want you to login as.

|improve this answer|||||
  • so do you mean this issue is because of the username i use to login, isn't the same one used while generating the private key? – MohammedSimba May 12 '15 at 13:03
  • @user225844 I'm... not sure what you're asking. Amazon generates the .pem file themselves, separately, before putting it on your EC2 instance. It automatically puts it in the default install user, 'ubuntu', per the EC2 images' installer configurations. You can put the key to other users, but you'll need to first get into the system as the 'ubuntu' user, then as root copy the authorized_keys file (or specific lines from it) to the other users' .ssh/authorized_keys in their home folders... – Thomas Ward May 12 '15 at 13:05
  • I got it, but Unfortunately i am not the one who created this instance on ec2, i just have the .pem file, so i only copied it to my machine, and changed the file permission to 600, but i always gets public key permission denied using any user "ubuntu, root, ec2-user" – MohammedSimba May 12 '15 at 13:11
  • @user225844 Then you need to start by talking to the person who set up the EC2 instance. They need to verify the users on the EC2 are set up to use that .pem with the system. They may need to manually do that configuration too. – Thomas Ward May 12 '15 at 13:14
  • So the username is causing that error, thank you for your support :) – MohammedSimba May 12 '15 at 13:28
1

This issue because i was using wrong .pem file, then i connected successfully as default users "ubuntu" on the amazon instance.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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