본인은 minimal 설치를 지향한다.
설치 시 루트계정의 패스워드는 입력하지 않는 편이다.
root 계정을 이용한다.
sudo su
보안 관련 세팅 (필요시, 모르고 진행하면 고통받을 수 있음)
sed -i "s/#PermetRootLogin yes/PermetRootLogin no/g" /etc/ssh/sshd_config &&\
sed -i "s/# lcredit = -1/lcredit = -1/g" /etc/security/pwquality.conf &&\
sed -i "s/# ucredit = -1/ucredit = -1/g" /etc/security/pwquality.conf &&\
sed -i "s/# dcredit = -1/dcredit = -1/g" /etc/security/pwquality.conf &&\
sed -i "s/# ocredit = -1/ocredit = -1/g" /etc/security/pwquality.conf &&\
sed -i "s/PASS_MAX_DAYS/PASS_MAX_DAYS 90#/g" /etc/login.defs &&\
sed -i "s/PASS_MIN_DAYS/PASS_MIN_DAYS 3#/g" /etc/login.defs &&\
sed -i "s/PASS_MIN_LEN/PASS_MIN_LEN 7#/g" /etc/login.defs &&\
sed -i "s/PASS_WARN_AGE/PASS_WARN_AGE 80#/g" /etc/login.defs &&\
chmod 750 /usr/bin/newgrp &&\
echo "export TMOUT=600" >> /etc/profile &&\
chmod 400 /etc/shadow &&\
chmod 600 /etc/hosts &&\
chmod 644 /etc/services &&\
echo "umask 027" >> /etc/profile
firewalld 삭제(필요시)
yum erase -y firewalld
필요한 유틸 설치 및 업데이트
yum install -y net-tools vim wget curl git chrony &&\
yum update -y
시간 세팅
timedatectl set-ntp true
history 명령어에 시간이 나오게 한다. (필요시 진행)
echo 'export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S -- "' >> /etc/profile
배너 세팅 (필요시)
cp -r /etc/update-motd.d /etc/update-motd.d_backup &&\
rm -rf /etc/update-motd.d/* &&\
touch /etc/update-motd.d/00-header &&\
chmod +x /etc/update-motd.d/00-header &&\
vim /etc/update-motd.d/00-header
#! /bin/sh
printf '+--------------------------------------------------------------------------+\n'
printf '| |\n'
printf '| 지금 접속하신 서버는 \033[32;1mㅁㅁㅁㅁㅁㅁ\033[0m 에서 서버를 관리하고 있습니다. |\n'
printf '| 모든 네트워크 연결을 \033[31;1m모니터링\033[0m하고 \033[31;1m기록\033[0m 되어지고 있으니 |\n'
printf '| \033[33;1m비인가자\033[0m의 경우 접속을 \033[31;1m해제\033[0m하시기 바랍니다. |\n'
printf '| |\n'
printf '+--------------------------------------------------------------------------+\n'
pem키 세팅
sed -i "s/PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config &&\
exit
cd &&\
ssh-keygen &&\
cd .ssh &&\
rm -rf * &&\
touch authorized_keys &&\
chmod 600 authorized_keys &&\
vim authorized_keys &&\
sudo systemctl restart sshd