美文网首页linux
Linux 安全加固

Linux 安全加固

作者: SkTj | 来源:发表于2019-01-17 15:16 被阅读59次

锁定不必要的账号:

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: '(2 == "") { print1 }' /etc/shadow


禁用不必要的服务

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: ‘(2 == “”) { print1 }’ /etc/shadow
3、检查是否有其他账号UID为0:
awk -F: '(3==0){print1}' /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、设置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、设置历史命令保留条数:
vi /etc/profile
HISTSIZE=5
10、vi /etc/host.conf
nospoof on


限制 at/cron给授权的用户:
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文件限制访问权限:
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.*
建立恰当的警告banner:
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
--
|
设置项 | 注释: |
| 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

| 这里仅作为参考,需根据实际需要调整参数 |
| 7 | 修改 SSH 端口和限制 IP 绑定:

Port 64906

安装selinux管理命令

yum -y install policycoreutils-python

修改 port contexts(关键),需要对context进行修改

semanage port -a -t ssh_port_t -p tcp 64906

semanage port -l | grep ssh —-查看当前SElinux 允许的ssh端口

| Vi /etc/ssh/sshd_config

仅作为参考,需根据实际需要调整参数。

|
| 8 | 禁用空密码:

PermitEmptyPasswords no

| 禁止帐号使用空密码进行远程登录SSH |
| 9 | 记录日志:

LogLevel INFO

| 确保在 sshd_config 中将日志级别 LogLevel 设置为 INFO 或者 DEBUG,可通过 logwatch or

logcheck 来阅读日志。

|
| 10 | 重启SSH

systemctl restart sshd.service

|

部署入侵检测工具:
AIDE

相关文章

  • linux安全加固

    对用户密码强度的设定 打开 /etc/pam.d/sysetm-auth 文件 ,修改如下。我们设置新密码不能和旧...

  • Linux安全加固

    锁定账号

  • Linux 安全加固

    锁定不必要的账号: passwd -l aapasswd -u xxx 密码策略 /etc/login.defsP...

  • Linux安全加固

    上次整理了 基于等保三级的win server 2012的加固方案(Windows安全加固),这次是基于等保三级的...

  • Linux操作系统加固

    Linux操作系统加固 本文旨在指导系统管理人员或安全检查人员进行Linux操作系统的安全合规性检查和加固。 1....

  • 系统加固之Linux安全加固

    Linux系统基本操作 文件结构图及关键文件功能介绍 Linux文件结构 Linux文件结构图 二级目录 | 目录...

  • Linux SSH安全加固

    Linux SSH 安全加固,这里使用CentOS7.5 做演示 一、配置SSH双因素登录 ​ ...

  • linux安全基线加固

    安全基线加固 一、帐号与口令-用户口令设置, 配置用户口令强度检查达到12位,要求用户口令包括数字、小写字母、大写...

  • Windows服务器安全加固10条建议

    上节我们介绍了“Linux安全加固10条建议”本节我们继续看Windows服务器安全加过10条建议。 以下是笔者刚...

  • 对 iOS app 进行安全加固

    对 iOS app 进行安全加固 对 iOS app 进行安全加固

网友评论

    本文标题:Linux 安全加固

    本文链接:https://www.haomeiwen.com/subject/utabdqtx.html