Solaris安全手册( 三 )


chmod 600 daemonlog authlog kernlog userlog maillog lprlog cronlog
newslog locallog alertlog;
kill -1 `pgrep syslogd`
使用rotate_log来修剪和压缩LOGS文件,在root cron中增加如下条目:
## Prune syslog logs weekly, keeping the last 6 months or so:
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 alertlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 authlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 20 cronlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 daemonlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 kernlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 locallog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 20 newslog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 40 userlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 10 lprlog
55 23 * * 6 /secure/rotate_log -L /var/log -c -m 600 -M 400 -c -s -n 20 maillog
# Reset syslog daemon
0,15,30 0 * * 0 kill -HUP `cat /etc/syslog.pid`
为了你自己使用上面的条目请在root cron中使其他的log修剪(pruning)无效:
#10 3 * * 0,4 /etc/cron.d/logchecker
#10 3 * * 0 /usr/lib/newsyslog
#15 3 * * 0 /usr/lib/fs/nfs/nfsfind
#1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1
#30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
Pruning of login & other logs:
## Empty login/logout records at year end
0 0 31 12 * /secure/wtrim.pl wtmp
0 0 31 12 * /secure/wtrim.pl wtmpx 20
# Solaris 2.x logs:
0 4 * * 6 /secure/rotate_log -L /var/adm -c -m 640 -M 440 -c -s -n 30 loginlog
0 4 * * 6 /secure/rotate_log -L /var/adm -c -m 640 -M 440 -c -s -n 30 sulog
0 4 * * 6 /secure/rotate_log -L /var/adm -c -m 640 -M 440 -c -s -n 2 vold.log
0 4 * * 6 /secure/rotate_cron
crons
删除不需要的crons:rm /var/spool/cron/crontabs/{lp,sys,adm}
Root cron 条目:
通过可信赖的来源使用rdate设定日期(你或许使用NTP协议,这将使时间精确一些,但正向上面所说的增加带宽和不必要的安全问题):
## Synchronise the time(同步时间):
0 * * * * /usr/bin/rdate YOURTIMEHOST >/dev/null 2>&1
文件权限
必须限制一些有关ROOT操作的权限或干脆使其无效:
chmod 0500 /usr/sbin/snoop /usr/sbin/devinfo
chmod o-r /var/spool/cron/crontabs/*
chmod 000 /bin/rdist
chmod o-rx /etc/security
chmod og-rwx /var/adm/vold.log
chmod u-s /usr/lib/sendmail #Except for mailgateways
chmod 400 /.shosts /etc/sshd_config /etc/ssh_known_hosts
再在登录信息上设置警告用户非授权登录的信息(如果要起诉侵入者你就需要这些信息) 。如在Telnet和SSH,在/etc/motd中设置警告语句:
ATTENTION: You have logged onto a secured XXXX Corporation server.
Access by non YYYY administrators is forbidden.
For info contact YYYY@XXX.com
重新启动,通过SSH登录,现在使用ps -e来显示进程列表:
PID TTY TIME CMD
0 ? 0:00 sched
1 ? 0:00 init
2 ? 0:00 pageout
3 ? 0:09 fsflush
156 ? 0:00 ttymon
152 ? 0:00 sac
447 ? 0:06 sshd
88 ? 0:00 inetd
98 ? 0:00 cron
136 ? 0:00 utmpd
605 ? 0:00 syslogd
175 console 0:00 ttymon
469 pts/1 0:00 csh
466 ? 0:01 sshd
625 pts/1 0:00 ps
及使用netstat -a 将显示最小的网络连接(如只有SSH):
UDP
Local Address Remote Address State
-------------------- -------------------- -------
*.syslog Idle
*.* Unbound
TCP
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
-------------------- -------------------- ----- ------ ----- ------ -------

推荐阅读