Linux는 Windows만큼이나 Security에 취약성을 보이지는 않는다고 하지만 그렇다고 해서 그냥 두고 볼 일은 아니죠. Security 침해를 방지하기 위한 최소한의 아니 될 수 있는 한 많은 부분에 대해서 강화를 해야 합니다. 그럼, 먼저 System File Protection 부분에서 Security를 강화 해 보도록 하죠.
System File Protection이라고 하면, Linux System 안에서 사용되고 있는 각 종 File 및 System Directory에 대한 Permission, Ownership, Attribute 등이 될 것 입니다.
1. Boot Loader
chmod 600 /boot/grub/grub.conf
chmod 600 /boot/lilo.conf
chattr +i /boot/grub/grub.conf
2. /tmp, /var/tmp에 1777 permission
chmod 777 /tmp /var/tmp
chmod +t /tmp /var/tmp
chgrp 0 /tmp
3. /, /usr, /var에 755 Permission
755이상의 Permission이 할당되어 있다면 문제의 여지가 많습니다.
chmod 755 / /usr /var
4. User Home Directory Permission
해당 User ID에 대해서만 User Read, Write, Execute만 부여하고 (700), Group, Other에 대해서는 어떠한 Permission도 부여하지 않는 것이 중요합니다.
chmod 700 /home/*
여기서 중요한 건 1회성에 그치지 않도록 User가 생성될 때 자동으로 700을 부여 할 필요가 있는데 이는 아래와 같이 하면 됩니다. UMASK 022가 Default 일텐데, 077로 고쳐주세요.
# vi /etc/login.defs
..
UMASK 077
..
여기서 UMASK는 Permission을 다르게 표기하는데, 그냥 777 – 022 => 755 , 777 – 077 => 700 이렇게 생각하시면 되요.
5. 각종 System File에 각각의 Permission 및 Attribute 부여
/var 관련 부분
chmod 751 /var/log
chmod 644 /var/log/messages
chmod 660 /var/log/wtmp #Who is logged in now. Use who to view
chmod 640 /var/log/lastlog #Who has logged in befor. Use last to view
chmod 600 /var/spool/cron/root
/etc 관련 부분
chmod 600 /etc/crontab
chmod 640 /etc/syslog.conf
chmod 640 /etc/logrotate.conf
chmod 600 /etc/ftpusers
chmod 644 /etc/passwd
chmod 400 /etc/shadow
chmod 400 /etc/gshadow
chmod 750 /etc/pam.d
chmod 600 /etc/hosts.allow /etc/hosts.deny
chmod 600 /etc/securetty #TTY interfaces that allow root logins
chmod 700 /etc/security
chmod 750 /etc/rc.d/init.d /etc/init.d
chmod 751 /etc/sysconfig
chmod 400 /etc/cron.allow /etc/cron.deny
chmod 400 /etc/ssh
chmod 400 /etc/sysctl.conf
chmod 600 /etc/xinetd.conf /etc/inetd.conf
chmod 600 /etc/login.defs
chmod 644 /etc/services /var/run/syslogd.pid
chmod -R g-w /etc
6. System Binary File에 Permission & Attribute 부여
chmod 4750 /bin/su
chattr +i /bin/su
chmod 750 /usr/sbin/useradd
chmod 750 /usr/bin/top
chmod 750 /sbin/fdisk
chmod 750 /sbin/mfs*
chmod 750 /sbin/fsck*
chattr +i /usr/sbin/useradd
chattr +i /usr/bin/top
chattr +i /sbin/fdisk
chattr +i /sbin/mkfs*
chattr +i /sbin/fsck*
chmod 100 /bin/ping /bin/ping6
chmod g-s /usr/bin/wall
chmod g-s /usr/bin/write
chmod u-s /usr/bin/rlogin
chmod u-s /bin/umount
chmod g-s /sbin/netreport
chmod u-s /usr/bin/rsh
필요에 따라서 설정을 잘 조정 해야하니 주의하세요.