Linux服务器安全加固(一)
来源:互联网 发布:ubuntu tty7 编辑:程序博客网 时间:2024/05/16 03:08
Linux服务器安全加固
1.创建 SU 用户组
方法:
vi /etc/group
添加一行 wheel:x:10:root,user1,user2
chgrp wheel /bin/su
chmod o-rwx /bin/su
2.SSH禁用root登陆更改默认端口
方法:vi /etc/ssh/sshd_config
把协议改为 2
PermitRootLogin = no
vi /etc/ssh/sshd_config
Port 22 改为其他端口
重启 sshd /etc/rc.d/init.d/sshd restart
3.禁用代码编译
方法:添加编译用户组 /usr/sbin/groupadd compiler ,cd /usr/bin
把常见的编译器所属组赋给编译用户组
chgrp compiler *cc*
chgrp compiler *++*
chgrp compiler ld
chgrp compiler as
设置 mysqlaccess 的访问
chgrp root mysqlaccess
设置权限
chmod 750 *cc*
chmod 750 *++*
chmod 750 ld
chmod 750 as
chmod 755 mysqlaccess
把用户添加到组里
修改/etc/group
compiler:x:520:user1,user2
4.限制inet服务
方法:限制访问 inet 服务
修改/etc/hosts.allow
建议格式:
#Approved IP addresses
ALL:192.168.0.1
ALL:192.168.5.2
#CSV uploader machine
proftpd:10.0.0.5
#pop3 from antwhere
ipop3:ALL
修改/etc/hosts.deny
ALL:ALL EXCEPT localhostENY
5.指定root登陆的tty
方法:vi /etc/securetty
只留 2 个连接
tty1
tty2
6.禁用特殊账户
方法:删除账户 userdel name
删除组 groupdel name
锁定特定账户:/usr/sbin/usermod -L -s /bin/false user
7.history配置
避免删除.bash_history 或重定向到/dev/null
方法:
chattr +a .bash_history
chattr +i .bash_history
8.限制非root执行命令
方法:
chmod 700 /bin/ping
chmod 700 /usr/bin/finger
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 700 /usr/bin/locate
chmod 700 /usr/bin/whereis
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/pico
chmod 700 /usr/bin/vi
chmod 700 /usr/bin/which
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/make
chmod 700 /bin/rpm
9.限制默认登陆密码长度
方法:
vi /etc/login.defs
PASS_M IN_LEN 10
10.检测rookit
方法:
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.md5
首先检查 md5 校验值: md5sum chkrootkit.tar.gz
然后解压安装
tar -zxvf chkrootkit.tar.gz
cd chkrootkit
./configure
make sense
然后运行./chkrootkit
我们可以将其添加到 contrab 使其每天自动扫描:
vi /etc/cron.daily/chkrootkit.sh
#!/bin/bash
# 输入 chkrootkit 的安装目录
cd /root/chkrootkit/
# 输入你想收到检测报告的 email
./chkrootkit | mail -s "Daily chkrootkit from Server Name" your@email.com
11.记录root登录事件
方法:
编辑/root 下的.bashrc ,当有 root 权限的用户登录时发生 email 通知
echo 'ALERT - Root Shell Access (Server Name) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -
d"(" -f2 | cut -d")" -f1`" your@email.com
12.关闭不用的服务和端口
方法:
略...
13.安装配置防火墙
方法:
略...
14.安装暴力破解检测
方法:
a.iptables
b.host.allow host.deny
c.crontab + 脚本 + host.deny
略...
15.内核加固
sysctl.conf 用来加固内核,目的是避免 DOS 和欺骗攻击
方法:
略...
0 0
- Linux服务器安全加固(一)
- Linux 服务器安全加固
- Linux服务器安全加固
- Linux服务器(redhat)的安全加固
- linux服务器安全加固shell脚本
- Linux服务器风险检测与安全加固
- 实战Linux服务器安全加固培训
- 实战Linux服务器安全加固培训
- Linux服务器风险检测与安全加固
- SQL服务器安全加固
- sql服务器安全加固
- 服务器安全加固BAT
- LINUX安全加固
- LINUX主机安全加固
- linux 安全加固
- linux安全加固
- linux 安全加固
- linux基础安全加固
- JSON数据格式删除问题
- Python初学第一篇
- bzoj1571 滑雪课
- HttpServletRequest中的数据
- leetcode 435. Non-overlapping Intervals
- Linux服务器安全加固(一)
- 大话设计模式(Python版)--代理模式
- 找不到 URLClassLoader$1.run() 行: 不可用 的源
- 高精度计算(二) /*高精度的加法运算*/
- CentOS7安装Nginx
- sobel算子
- MyBatis 多表联合查询及优化
- python笔记---需求文件requirements.txt的创建及使用
- Oracle 的入门心得