Aws

EC2 사용자 데이터

wngnl05 2024. 12. 24. 13:26

Port번호 & PassWord

#!/bin/bash
echo 'Port (포트 번호)' >> /etc/ssh/sshd_config
systemctl restart sshd
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
echo "<AMI 이름>:<비밀번호>" | chpasswd
systemctl restart sshd

AWS 자격증명

mkdir /home/ec2-user/.aws
touch /home/ec2-user/.aws/credentials
touch /home/ec2-user/.aws/config
chmod 777 /home/ec2-user/.aws/
chmod 777 /home/ec2-user/.aws/credentials
chmod 777 /home/ec2-user/.aws/config
cat <<EOF >> /home/ec2-user/.aws/credentials
[default]
aws_access_key_id = <KEY_ID>
aws_secret_access_key = <SECRET KEY ID>
EOF
cat <<EOF >> /home/ec2-user/.aws/config
[default]
region = ap-northeast-2
output = json
EOF