Amazon ECS ์ต์ ํ AMI ์์ EC2 ์ธ์คํด์ค ์ฐ๊ฒฐ ์๋ํฌ์ธํธ ์ฌ์ฉํ๊ธฐ
Failed to connect to your instance
Error establishing SSH connection to your instance. Try again later.
ECS ํด๋ฌ์คํฐ์ EC2 ์ฉ๋ ๊ณต๊ธ์๋ฅผ ํตํด ์คํ ์ค์ผ์ผ๋ง ๊ทธ๋ฃน(ASG)์ผ๋ก ํ๋ผ์ด๋น ์๋ธ๋ท์ ์คํ๋ EC2 ์ธ์คํด์ค์ EC2 Instance Connect ์๋ํฌ์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ฐ๊ฒฐ์ ์คํจํ์ต๋๋ค. AWS ๋ฌธ์์ ๋ฐ๋ฅด๋ฉด, Amazon ECS-optimized Linux AMIs๋ ec2-instance-connect ์ค์น๊ฐ ๊ฐ๋ฅํ๋ฉฐ ์ต์ Amazon Linux ๋ฒ์ ์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํฌํจํ๊ณ ์๋ค๊ณ ๋์์์ง๋ง Amazon ECSโoptimized AMI(al2023-ami-ecs-hvm-2023.0.20241031-kernel-6.1-arm64)์์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ค์น๋ ํจํค์ง๊ฐ ์๋๋๋ค.
$ yum list installed | grep ec2
amazon-ec2-net-utils.noarch 2.5.1-1.amzn2023.0.1 @System
cloud-init-cfg-ec2.noarch 22.2.2-1.amzn2023.1.12 @System
dracut-config-ec2.noarch 3.0-4.amzn2023.0.2 @System
ec2-utils.noarch 2.2.0-1.amzn2023.0.1 @System
grub2-efi-aa64-ec2.aarch64 1:2.06-61.amzn2023.0.12 @System
$ sudo dnf install ec2-instance-connect -y
$ sudo cat /etc/ssh/sshd_config | grep AuthorizedKeysCommand
AuthorizedKeysCommand /opt/aws/bin/eic_run_authorized_keys %u %f
AuthorizedKeysCommandUser ec2-instance-connect
$ sudo dnf --releasever=latest update -y
Amazon ECS Optimized AMI์ ์ฌ์ฉ์ ๋ฐ์ดํฐ๋ก ec2-instance-connect ํจํค์ง ์ค์นํ๊ธฐ
ECS ํด๋ฌ์คํฐ์ ์คํ ์ค์ผ์ผ๋ง ๊ทธ๋ฃน์์ EC2 ์ธ์คํด์ค๋ฅผ ์คํํ ๋ ์ฌ์ฉํ๋ ์์ ํ ํ๋ฆฟ์ ์ฌ์ฉ์ ๋ฐ์ดํฐ ์คํฌ๋ฆฝํธ๋ก EC2 Instance Connect ์๋ํฌ์ธํธ ์ฐ๊ฒฐ์ ์ํ ํจํค์ง๋ฅผ ์ค์นํ ์ ์์ต๋๋ค.
$ sudo dnf list installed | grep ec2
amazon-ec2-net-utils.noarch 2.5.1-1.amzn2023.0.1 @System
cloud-init-cfg-ec2.noarch 22.2.2-1.amzn2023.1.12 @System
dracut-config-ec2.noarch 3.0-4.amzn2023.0.2 @System
ec2-instance-connect.noarch 1.1-19.amzn2023 @amazonlinux
ec2-instance-connect-selinux.noarch 1.1-19.amzn2023 @amazonlinux
ec2-utils.noarch 2.2.0-1.amzn2023.0.1 @System
grub2-efi-aa64-ec2.aarch64 1:2.06-61.amzn2023.0.12 @System