Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I'm trying to connect via SSH. It was ok, but after some manipulations by me :-[ I've downloaded keypairs, copy to .ec2, chmod to 600, ssh-keygen -y -f ~/.ec2/gsg-keypair > ~/.ec2/ I'm using MacOS. I think it's something wrong with permissions... but I've tried all combinations and all recommendations )

.ec2/ ls -l
-rw-------@ 1 olegpasko staff 1692 Apr 2 02:26 gsg-keypair
-rw-r--r-- 1 olegpasko staff 381 Apr 2 10:55

.ssh/ ls -l
-rw------- 1 olegpasko staff 1766 Jun 8 2012 github_rsa
-rw-r--r-- 1 olegpasko staff 398 Jun 8 2012
-rw------- 1 olegpasko staff 398 May 25 2012 github_rsa.pub_bak-github
-rw------- 1 olegpasko staff 1766 May 25 2012 github_rsa_bak-github
-rw------- 1 olegpasko staff 1766 Jun 28 2012 id_rsa
-rw-r--r-- 1 olegpasko staff 401 Jun 28 2012
drw------- 2 olegpasko staff 68 Jun 28 2012 key_backup
-rw-------@ 1 olegpasko staff 5218 Apr 2 02:29 known_hosts
-rw-------@ 1 olegpasko staff 5218 Mar 31 13:55 known_hosts.bak

Trying to connect:

ssh -i gsg-keypair -v
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to port 22.
debug1: Connection established.
debug1: identity file gsg-keypair type 1
debug1: identity file gsg-keypair-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
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: Server host key: RSA 43:81:01:0d:a6:ff:9d:85:48:18:97:7a:12:4a:16:27
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /Users/olegpasko/.ssh/known_hosts:13
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_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/olegpasko/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: gsg-keypair
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).


share|improve this question
'but after some manipulations by me' what manipulations? did you changed anything at /etc/ssh/sshd_config related to keypair auth? – Marcel Apr 4 '13 at 20:50
yeah, manipulations is keyword... but no, I don't remember manipulations with sshd_config file :( – ANATHEM Apr 4 '13 at 21:27
up vote 1 down vote accepted

You need to fix your sshd config. You can do this by following the "EBS-Backed Instances :: Instance Recovery" section of .

Step 4: "Correct the configuration on the old root volume." is where you need to un-manipulate your sshd_config.

Since instance and volume manipulation is painfully slow, you should test that your de-fubarred sshd_config works by starting an sshd on a different port using the config. Be sure the security group of the instance allows connections to that port.

share|improve this answer
Thanks! I've just unmount volume, then mount to another instance and vice versa and it works now ) And user ubuntu has appeared. – ANATHEM Apr 5 '13 at 11:47

Assuming you're using an Amazon Linux AMI, root logins are disabled. Try ssh -i gsg-keypair -v

share|improve this answer
Permission denied (publickey) again ( In console example with root... Connect with a standalone SSH Client... Example Enter the following command line: ssh -i gsg-keypair.pem And it worked some days ago. – ANATHEM Apr 2 '13 at 13:20
@ANATHEM Ah, it looks like you're using Ubuntu anyhow. Which AMI? The packager might be using a different unprivileged user name. – jamieb Apr 2 '13 at 13:23
Ubuntu Server 12.04.1 LTS x64 ... I have deployer user, created previously. With deployer the same situation. – ANATHEM Apr 2 '13 at 13:26
@ANATHEM Where did you get the AMI though? What's the ID number? – jamieb Apr 2 '13 at 13:34
jamiebl, what did you mean 'where'? This is simple micro instance in eu-west-1 region, created in EC2 console :) Id is i-8c75d4c6 – ANATHEM Apr 2 '13 at 13:46

Your Answer


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.