I cant connect to my instance on ec2. All was ok early, and I think now problem in ufw.
When I configured my server I enable ufw for 80 port and maybe its disable 22 port. Because early all was ok, but now i cant connect by ssh.
How can i connect to my ec2 instance and allow 22 port again?
You could use the following simplest way (user-data) to turn off the ufw then access the instance and edit your firewall.
Following is the user data:
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, once]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
sudo ufw disable
--//
See my answer here enable firewall port 22 on ec2 server after disable it
You have to check the security group under the EC2 instance and enable/add the port 22 over there. After that you can check the apache on port 80.
If you have accidently blocked the port then us this link to reset it again https://u.osu.edu/walujo.1/2017/04/21/how-to-fix-ec2-instance-when-you-accidentally-block-port-22/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With