鎖定不必要的賬號:
passwd -l aa
passwd -u xxx
密碼策略
/etc/login.defs
PASS_MAX_DAYS 90
PASS_MIN_DAYS 0
PASS_WARN_AGE 7
PASS_MIN_LEN 9
檢查空密碼 awk -F: '(
1 }' /etc/shadow
禁用不必要的服務(wù)
runlevel
chkconfig --list
chkconfig xx on/off
vi /etc/profile
umask=022
--
ssh
AllowUsers *@192.168.1.0 xx
PermitRootLogin no
banner NONE
注銷時間
/etc/profile
TMOUT=600
HISTSIZE=5
HISTFILESIZE=5
1始腾、刪除用戶:operator lp shutdown halt games gopher
刪除用戶組:lp uucp games dip
2、查看是否有空密碼:awk -F: ‘(1 }’ /etc/shadow
3达舒、檢查是否有其他賬號UID為0:
awk -F: '(1}' /etc/passwd
4瞎访、是否有用戶目錄下的.文件是其他人可以讀寫的
for dir in \
awk -F: ‘($3 >= 500) { print $6 }’ /etc/passwd
do
for file in $dir/.[A-Za-z0-9]*
do
if [ -f $file ]; then
chmod o-w $file
fi
done
done
5腻贰、設(shè)置umask
6、 vi /etc/login.defs
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
7扒秸、限制su的用戶
限制能夠su為root 的用戶:#vi /etc/pam.d/su
在文件頭部添加下面這樣的一行
auth required pam_wheel.so use_uid
這樣播演,只有wheel組的用戶可以su到root
操作樣例:
usermod -G10 test 將test用戶加入到wheel組
8、修改自動注銷
vi /etc/profile
TMOUT=600
9鸦采、設(shè)置歷史命令保留條數(shù):
vi /etc/profile
HISTSIZE=5
10宾巍、vi /etc/host.conf
nospoof on
限制 at/cron給授權(quán)的用戶:
cd /etc/
rm -f cron.deny at.deny
echo root >cron.allow
echo root >at.allow
chown root:root cron.allow at.allow
chmod 400 cron.allow at.allow
Crontab文件限制訪問權(quán)限:
chown root:root /etc/crontab
chmod 400 /etc/crontab
chown -R root:root /var/spool/cron
chmod -R go-rwx /var/spool/cron
chown -R root:root /etc/cron.*
chmod -R go-rwx /etc/cron.*
建立恰當?shù)木鎎anner:
echo “Authorized uses only. All activity may be \
monitored and reported.” >>/etc/motd
chown root:root /etc/motd
chmod 644 /etc/motd
echo “Authorized uses only. All activity may be \
monitored and reported.” >> /etc/issue
echo “Authorized uses only. All activity may be \
monitored and reported.” >> /etc/issue.net
chown root:root /etc/sysctl.conf
chmod 600 /etc/sysctl.conf
chkconfig postfix off
--
|
設(shè)置項 | 注釋: |
| 1 | 配置空閑登出的超時間隔:
ClientAliveInterval 300
ClientAliveCountMax 0
| Vi /etc/ssh/sshd_config |
| 2 | 禁用 .rhosts 文件
IgnoreRhosts yes
| Vi /etc/ssh/sshd_config |
| 3 | 禁用基于主機的認證
HostbasedAuthentication no
| Vi /etc/ssh/sshd_config |
| 4 | 禁止 root 帳號通過 SSH 登錄
PermitRootLogin no
| Vi /etc/ssh/sshd_config |
| 5 | 用警告的 Banner
Banner /etc/issue
| Vi /etc/ssh/sshd_config |
| 6 | iptables防火墻處理 SSH 端口 # 64906
-A INPUT -s 192.168.1.0/24 -m state –state NEW -p tcp –dport 64906 -j ACCEPT
-A INPUT -s 202.54.1.5/29 -m state –state NEW -p tcp –dport 64906 -j ACCEPT
| 這里僅作為參考,需根據(jù)實際需要調(diào)整參數(shù) |
| 7 | 修改 SSH 端口和限制 IP 綁定:
Port 64906
安裝selinux管理命令
yum -y install policycoreutils-python
修改 port contexts(關(guān)鍵)渔伯,需要對context進行修改
semanage port -a -t ssh_port_t -p tcp 64906
semanage port -l | grep ssh —-查看當前SElinux 允許的ssh端口
| Vi /etc/ssh/sshd_config
僅作為參考顶霞,需根據(jù)實際需要調(diào)整參數(shù)。
|
| 8 | 禁用空密碼:
PermitEmptyPasswords no
| 禁止帳號使用空密碼進行遠程登錄SSH |
| 9 | 記錄日志:
LogLevel INFO
| 確保在 sshd_config 中將日志級別 LogLevel 設(shè)置為 INFO 或者 DEBUG锣吼,可通過 logwatch or
logcheck 來閱讀日志选浑。
|
| 10 | 重啟SSH
systemctl restart sshd.service
|
部署入侵檢測工具:
AIDE