Burak
Burak

Reputation: 5774

Error while connecting to EC2 instance

Here is the log :

macs-MacBook-Air:~ mac$ ssh -v -i sohoKey.pem [email protected] 
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to ec2-107-22-101-75.compute-1.amazonaws.com [107.22.101.75] 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 'ec2-107-22-101-75.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).

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 [email protected]

Upvotes: 0

Views: 588

Answers (3)

Burak
Burak

Reputation: 5774

I detached my EBS Volume from the instance. After that I created a new instance then I attached the 8GB EBS to that.

After that, I mounted that instance to /mybackup.

So I could reach my data from /mybackup/...

Thank you for your suggestions.

But I still don't know, why my key pair has gone?

Upvotes: 0

Graham Smith
Graham Smith

Reputation: 25757

You could try bringing up a new instance then disconnecting the storage from the one you have lost the key pair to, and then adding it to the new instance.

Another option, but I haven't tried, is to create a new image out of the current instance. When this is complete, create a new instance of the new image and create a new key pair.

Either way you have lost the ability to connect and you cannot add a new key pair (as far as I know) to an instance.

Upvotes: 1

Frederick Cheung
Frederick Cheung

Reputation: 84182

Creating a keypair with the same name won't help - it's the data in it that counts.

It's also not possible to change the keypair on a running instance, i don't believe there is anything you can do. If there is data that you want to recover from the instance and the volume is an EBS volume then you can mark the volume as not to be deleted on termination. After terminating the instance the volume should be left intact and you'll be able to attach it to a different instance.

Upvotes: 2

Related Questions