Ubuntu는 기본 방화벽으로 ufw를 사용한다. 이 때, ufw를 disable 했다가 enable 했을 때, ssh 접속이 다시 되지 않는 경우가 있다.
아래 코드로 바꿔 넣으면 된다.
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, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
ufw disable
iptables -L
iptables -F
--//
해당 코드는 아래 링크를 참조하면 된다.
https://medium.com/@manprajapat/cant-access-ssh-after-enable-ufw-in-ec2-aws-koffee-with-kode-5e481a5631c6
인스턴스 다시 시작
SSH 접속 가능해짐.