Ssh – Accidentally port 22 got closed, how to fix the SSH access

amazon ec2awsssh

Accidentally, Port 22 got closed. I cannot ssh into the instance, though the instance are running well on other desired ports. Getting following error while doing SSH.

ssh: connect to host X.X.X.X port 22: Connection refused

I restarted the instance, but still ssh is not working.
The security groups are open for port 22 from anywhere(0.0.0.0/0).

I was trying to set the default welcome message after SSH on the machine by editing /etc/ssh/sshd_config file. Just after editing and reloading the ssh with the following command I was unable to ssh again.

sudo service ssh reload

Best Answer

I did it by detaching the volume from the current instance than added it to the other instance as a secondary volume. Than the volume become readable, and I changed the ssh config file to default one. Detached the volume and added back to the original instance

Related Question