새 서버를 세팅할 때마다 보안 설정을 반복하는데, 자동화 스크립트를 만들 수 있나요?
서버 초기 보안 설정 자동화:
#!/bin/bash# server-init.shset -eecho "=== 시스템 업데이트 ===" sudo apt update && sudo apt upgrade -yecho "=== 기본 패키지 설치 ==="sudo apt install -y ufw fail2ban unattended-upgrades curlecho "=== SSH 보안 ===" sudo sed -i "s/#PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_configsudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_configsudo systemctl restart sshdecho "=== 방화벽 ===" sudo ufw default deny incomingsudo ufw default allow outgoingsudo ufw allow sshsudo ufw allow 80/tcpsudo ufw allow 443/tcpsudo ufw --force enableecho "=== fail2ban ==="sudo systemctl enable fail2bansudo systemctl start fail2banecho "=== 자동 업데이트 ==="sudo dpkg-reconfigure -plow unattended-upgradesecho "✅ 초기 보안 설정 완료"
이 스크립트를 GitHub에 올려두고 새 서버마다 실행하면 됩니다.
댓글 1
서버 초기 보안 설정 자동화:
이 스크립트를 GitHub에 올려두고 새 서버마다 실행하면 됩니다.