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


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? Dec 25, 2019 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 Dec 25, 2019 at 11:18

1 Answer 1


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.

  • It seems an ubuntu instance will not persist the journal file. SSH is configured to log to AUTH, so /var/log/auth.log
    – Andy
    Dec 20, 2020 at 16:51
  • You can create /var/log/journal directory to make it persistent. Dec 20, 2020 at 17:51
  • True, but we're talking about an investigation after the fact, so that doesn't help.
    – Andy
    Dec 20, 2020 at 17:53

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.