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.

In AWS console, I saw that my key pair was deleted. I created a new one with the same name. Then I tried to connect with ssh -v -i sohoKey.pem ec2-user@******.compute-1.amazonaws.com

Here's the output:

macs-MacBook-Air:~ mac$ ssh -v -i sohoKey.pem ec2-user@******.compute-1.amazonaws.com 
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to ********.compute-1.amazonaws.com [*****] port 22.
debug1: Connection established.
debug1: identity file sohoKey.pem type -1
debug1: identity file sohoKey.pem-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 '*******.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/mac/.ssh/known_hosts:3
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: sohoKey.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: sohoKey.pem

debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

Update: I detached my old EBS and attached to the new instance. Now, how can I mount it?

share|improve this question
1  
After you created the new key pair, did you upload the new public key to Amazon? Your EC2 instance (actually, any SSH server) won't accept logins from a key it doesn't know about. –  Wyzard Mar 31 '12 at 18:19
add comment

1 Answer

If you don't have the correct matching key for an instance, the server won't let you in. Keys that are registered with EC2 are only set up in an image during initialization, so you can't change it while the machine is online.

If you have an EBS volume, you can re-attach it as a secondary volume of a new instance, fix your mistake by loading the new key on it, then attach it back to the old instance. Otherwise, you've lost your server.

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.