1

TL;DR: Can't SSH to my EC2 instance after upgrading Ubuntu.

I set up a EC2 instance with Bitnami Wordpress AMI. The image has Ubuntu 16.04 and I want Ubuntu 18.04 so I connected to the instance via SSH using PuTTY with

ubuntu@ec2-{ip}.compute-1.amazonaws.com

and once inside I did

sudo do-release-upgrade

During upgrade I was prompted to choose between updating or preserving ssh_config. I chose to preserve it because I wanted to use the SSH key I had set for the instance.

I was prompted to reboot the instance which I did. After reboot the server works (I can connect to it from my browser) but I can't connect via SSH. PuTTY error message is

Network error: Connection refused.

I did notice the ip changed after reboot and I did use the new ip when trying to connect.

Additionally: I don't know how to check the contents of ssh_config or if the SSH service is running without connecting via SSH.

  • Try to obtain the console log. Check if the machine has booted. Can you access any service? Is it answering to ping? – Mircea Vutcovici Dec 25 '19 at 7:27
  • @MirceaVutcovici The site is up so it has booted. From AWS console I can get system log. I notice it tries to start SSH multiple times but fails. Here is a relevant snippet pastebin.com/GSSEuVTi – Markus Uusitalo Dec 25 '19 at 11:18
0

You need to stop the VM and attach its disk to another new temporary VM. Then check the logs (journalctl -b --file=/path/to//var/log/journal/....). Fix the syntax error in /path/to/etc/ssh/sshd_config. Verify the sshd config with sshd -T -f /path/to/etc/ssh/sshd_config. Detach the disk, then try to boot again the machine.

| 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.