Why my instance suddenly cannot be accessed via SSH?

0

In the past, I was able to connect to my instance using SSH, and even used VS Code remote-ssh to connect without any issues. However, today I suddenly cannot connect anymore. When I try to connect using Terminal, I get a message saying the connection is refused. I checked the security rules for my instance, and my IP address is already added to the inbound rules, so it shouldn't be blocked by the firewall. What should I do?

5 Answers
0

Hi, both status checks of my instance show normal, and there is no indication of abnormalities. However, the website still cannot be accessed, which is somewhat strange. It seems that AWS customer service requires payment to assist with this issue.

answered a year ago
  • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-console.html
    Have you tried checking the logs using the "instance console output" method?

  • Hi, I tried. There is nothing error on it.

    Starting Postfix Mail Transport Agent... [ OK ] Started Postfix Mail Transport Agent. [ 16.383767] cloud-init[1444]: Cloud-init v. 23.1.1-0ubuntu018.04.1 running 'modules:config' at Sun, 09 Apr 2023 12:35:29 +0000. Up 16.25 seconds. [ OK ] Started Apply the settings specified in cloud-config. Starting EC2 instance hibernation setup agent... [ OK ] Started EC2 instance hibernation setup agent. [ OK ] Reached target Multi-User System. [ OK ] Reached target Graphical Interface. Starting Update UTMP about System Runlevel Changes... Starting Execute cloud user/final scripts... [ OK ] Started Update UTMP about System Runlevel Changes. [ 17.266236] cloud-init[2026]: Cloud-init v. 23.1.1-0ubuntu018.04.1 running 'modules:final' at Sun, 09 Apr 2023 12:35:30 +0000. Up 17.10 seconds. [ 17.278597] cloud-init[2026]: Cloud-init v. 23.1.1-0ubuntu0~18.04.1 finished at Sun, 09 Apr 2023 12:35:30 +0000. Datasource DataSourceEc2Local. Up 17.25 seconds [ OK ] Started Execute cloud user/final scripts. [ OK ] Reached target Cloud-init target. 2023/04/09 12:35:30Z: Amazon SSM Agent v3.1.1732.0 is running 2023/04/09 12:35:30Z: OsProductName: Ubuntu 2023/04/09 12:35:30Z: OsVersion: 18.04

    Ubuntu 18.04.6 LTS ip-172-31-13-57 ttyS0

    ip-172-31-13-57 login:

  • I see from the logs that the SSM agent is installed.
    If that's the case, try logging in with session manager and checking the sshd status, etc.
    The Session Manager can be used in the following ways.
    https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager.html

0

Has your IP address changed, etc.?
Check your IP address to be sure.
It is recommended to check network ACLs and security groups afterwards.
https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

If this does not solve the problem, you can also try to connect using Session Manager.
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager.html

profile picture
EXPERT
answered a year ago
0

How can I check the firewall settings? I have checked my security group, and the settings seem normal: sgr-050eaa7e60aa4aa89 IPv6 HTTPS TCP 443 ::/0 –

– sgr-02fb68a313da3f4bc IPv4 SSH TCP 22 0.0.0.0/0 –

– sgr-02634c3a46d3011ce IPv4 HTTPS TCP 443 0.0.0.0/0 –

– sgr-0d58092cd29d7b455 IPv4 Custom TCP TCP 34210 0.0.0.0/0 runcloud

– sgr-0aa5912a1d4962712 IPv6 HTTP TCP 80 ::/0 –

– sgr-0751e7b1cb5ff144e IPv4 HTTP TCP 80

The worst thing is that after I restarted the instance, even the website inside cannot be accessed anymore, and it seems that AWS charges a fee to help fix the problem.

answered a year ago
0

Doesn't sound like a problem with security groups, etc.
Are there any abnormalities in the EC2 status?
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-system-instance-status-check.html
The following documents are common troubleshooting steps to take when you cannot connect to an instance.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-console.html
Follow the instructions in the "Instance console output" section and check the logs.
If sshd is stopped for some reason, the instance must be restarted.

profile picture
EXPERT
answered a year ago
0

The Session Manager can be used in the following ways.
https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager.html
After logging in with Session Manager, check the status of sshd with the following command.

sudo systemctl status sshd

If it is stopped, restart sshd with the following command.

sudo systemctl restart sshd
profile picture
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions