Security Group (보안 그룹) 설정을 내 IP로 하면
당연히 EC2 인스턴트에 무리없이 연결 될 줄 알았는데...
웹 상에서 인스턴스에 연결은 안되었다....
친절한 오류메시지 내역
| We were unable to connect to your instance. Make sure that your instance’s network settings are configured correctly for EC2 Instance Connect. For more information, see Task 1: Configure network access to an instance. |
당연하게도
Security Group에서 22(SSH)를 0.0.0.0/0 으로 설정하면 된다...
하지만 이것은 치명적인 보안 문제가 있기 때문에 권장하지 않습니다.
해결방법
1. 우선 보안 그룹(Security Group)에서 22포트에 대해 0.0.0.0/0으로 설정 뒤 웹으로 연결 한다.
2. 다음 명령어를 사용하여 내가 접속하는 웹의 접근 IP 대역을 체크한다. (서울 리전 기준!)
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json| jq -r '.prefixes[] | select(.region=="ap-northeast-2") | select(.service=="EC2_INSTANCE_CONNECT") | .ip_prefix'
13.209.1.56/29
※ Amazone Linux 2 AMI 설치 내역임
※ 설치된 명령어(curl, jd )
* 없을 경우 #> yum install jd 와 같은 명령어로 설치함.
3. 위의 설정 값을 기준으로 다시 보안 그룹 (Security Group)을 재 설정한다.
* xxx.xxx.xxx.130 은 내 IP로 설정한 고정 IP 주소
* 위의 웹 접근시 나온 정보 (13.209.1.26/29)를 SSH 접근하도록 설정하면 EC2를 웹에서 연결 가능함.

참고 URL : https://stackoverflow.com/questions/66884055/elastic-beanstalk-ec2-instance-connect-cant-connect
Elastic Beanstalk & EC2 Instance Connect: Can't connect
I created an Elastic Beanstalk environment from Visual Studio and need to login to service the underlying ec2 vm. I don't have an credentials for the server, so I wanted to use EC2 Instance Connect...
stackoverflow.com
참고 URL : https://aws.amazon.com/ko/premiumsupport/knowledge-center/ec2-instance-connect-troubleshooting/
EC2 Instance Connect를 사용한 연결 문제 해결
Amazon EC2 Instance Connect를 사용하여 Amazon EC2(Amazon Elastic Compute Cloud) 인스턴스에 연결하려고 할 때 다음 오류가 표시됩니다. “ 인스턴스 연결을 설정하는 동안 문제가 발생했습니다. 로그인하지 못
aws.amazon.com