1

I have Ubuntu 14.04 server (LAMP), running on Amazon ec2. On my client machine I run Putty with imported SSH key. Session is saved, so there is no changes always. I had no errors during connection and everything was fine. But today I've made apt-get update and reboot. Now I see Using username "ubuntu". Server refused our key error and promt to enter password. I've already tried to Stop and Start instace, but that doesn't help.

5
  • Did you double check that your Putty session is still pointing to the private key under Connection - SSH - Auth? Putty does not save changes to session automatically. Oct 8, 2014 at 14:50
  • Yes, I've checked it. I've used Save session button previously.
    – Max Power
    Oct 8, 2014 at 16:48
  • Now I have another error. Server unexpectedly closed network connection
    – Max Power
    Oct 8, 2014 at 19:02
  • Sorry if this sounds stupid, but are you sure you're connecting to the right instance? The public dns and ip address may change when you stop/start, unless you have an Elastic IP assigned. Oct 8, 2014 at 19:07
  • @David Levesque Yes, I'm sure, that it's right instance and I have Elastic IP assigned. Restarted the server 1 more time. I've tried both Public DNS and IP for connection. It's refusing my key and wants password.
    – Max Power
    Oct 8, 2014 at 19:30

2 Answers 2

1

If nothing else works, what you could do is to create an AMI image from your current instance, and then launch a new instance from that AMI. When you launch the new instance, you will have the option to create a new private key or use an existing one. If you can connect to the new instance, just terminate the old one and reassign the Elastic IP to the new one.

Edit: If you still can't connect to the new instance, you could fire a new instance (using a vanilla Ubuntu AMI, not your own) and then mount the EBS volume of your broken instance into the new instance. This would allow you to have access to the filesystem of the broken instance and maybe find a way to fix it, or at least, copy files from it. The detailed steps are described in this post.

4
  • Done it. Got the same error during connection with new ip and key.
    – Max Power
    Oct 8, 2014 at 21:01
  • So you created a new key, downloaded it and converted the private key using PuttyGen? Oct 8, 2014 at 21:07
  • Yes, thats right, I've done it after performing steps in your answer. It looks like there are some problems with SSH service in image after update.
    – Max Power
    Oct 8, 2014 at 21:12
  • That's odd. See my edit. Oct 8, 2014 at 21:35
0

Try to launch a new ubuntu instance and follow the steps mentioned in the link below: https://www.google.com/search?q=how+to+recover+ssh+in+aws+instance&oq=how+to+recover+ssh+in+aws&aqs=chrome.1.69i57j33l7.13309j0j4&sourceid=chrome&ie=UTF-8

I would recommend to use session manager installed and with an ssm-agent and policy attached. It is possible to access the terminal session

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .