CentOS 6服务器简单安全配置
来源:互联网 发布:sm1算法多少钱 编辑:程序博客网 时间:2024/05/18 03:24
1. 禁用不使用的用户
cp /etc/passwd{,.bak}修改之前先备份
vi /etc/passwd编辑用户,在前面加上#注释掉此行
# cat /etc/passwd|grep ^##adm:x:3:4:adm:/var/adm:/sbin/nologin#lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin#shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown#halt:x:7:0:halt:/sbin:/sbin/halt#uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin#operator:x:11:0:operator:/root:/sbin/nologin#games:x:12:100:games:/usr/games:/sbin/nologin#gopher:x:13:30:gopher:/var/gopher:/sbin/nologin#ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin#nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin#postfix:x:89:89::/var/spool/postfix:/sbin/nologin
# cat /etc/group|grep ^##adm:x:4:adm,daemon#lp:x:7:daemon#uucp:x:14:#games:x:20:#gopher:x:30:#video:x:39:#dip:x:40:#ftp:x:50:#audio:x:63:#floppy:x:19:#postfix:x:89:
2. 关闭不使用的服务
# chkconfig --list |grep '3:on'
通用unix打印服务,对服务器无用:```shellservice cups stopchkconfig cups --level 2345 off
service cpuspeed stopchkconfig cpuspeed --level 2345 off
service bluetooth stopchkconfig bluetooth --level 2345 off
service firstboot stopchkconfig firstboot --level 2345 off
service netfs stopchkconfig netfs --level 2345 offservice nfslock stopchkconfig nfslock --level 2345 off
service acpid start && chkconfig acpid on
3. 禁用IPV6
禁止加载IPv6模块
alias net-pf-10 offoptions ipv6 disable=1
# vi /etc/sysconfig/networkNETWORKING_IPV6=no
# vi /etc/sysconfig/network-scripts/ifcfg-eth0IPV6INIT=noIPV6_AUTOCONF=no
# chkconfig ip6tables off
# lsmod | grep ipv6# ifconfig | grep -i inet6
4. iptables规则
5. SSH安全设置
# useradd crm -d /apps/crm# passwd crm# useradd sysmgr# passwd sysmgr
5.1 只允许wheel用户组的用户su切换
# usermod -G wheel sysmgr# vi /etc/pam.d/su# Uncomment the following line to require a user to be in the "wheel" group.auth required pam_wheel.so use_uid
5.2 登录超时
export TMOUT=300readonly TMOUT
5.3 禁止root直接远程登录
# vi /etc/ssh/sshd_configPermitRootLogin no
5.4 限制登录失败次数并锁定
auth required pam_tally2.so deny=6 unlock_time=180 even_deny_root root_unlock_time=180
5.5 登录IP限制
## allowed ssh users sysmgrAllowUsers sysmgr@172.29.73.*
vi /etc/hosts.denysshd:all
vi /etc/hosts.allowsshd:172.29.73.23sshd:172.29.73.
6. 配置只能使用密钥文件登录
[dir@username ~]$ ssh-keygen -t rsa -b 2048Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): //默认路径,回车Enter passphrase (empty for no passphrase): //输入你的密钥短语,登录时使用Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:3e:fd:fc:e5:d3:22:86:8e:2c:4b:a7:3d:92:18:9f:64 root@ibpak.tp-link.netThe key's randomart image is:+--[ RSA 2048]----+| |…| o++o..oo..o|+-----------------+
$ mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys$ chmod 600 ~/.ssh/authorized_keys
RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys
Match User itsection PasswordAuthentication no
7. 减少history命令记录
vi /etc/profile
8. 增强特殊文件权限
chattr +i /etc/passwdchattr +i /etc/shadowchattr +i /etc/groupchattr +i /etc/gshadowchattr +i /etc/services #给系统服务端口列表文件加锁,防止未经许可的删除或添加服务chattr +i /etc/pam.d/suchattr +i /etc/ssh/sshd_config
lsattr /etc/passwd /etc/shadow /etc/services /etc/ssh/sshd_config
9. 防止一般网络攻击
9.1 禁ping
# echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -j DROP
iptables -A OUTPUT -p icmp --icmp-type 8 -j DROP
9.2. 防止IP欺骗
order hosts,bind #名称解释顺序multi on #允许主机拥有多个IP地址nospoof on #禁止IP地址欺骗
9.3 防止DoS攻击
* soft core 0* soft nproc 2048* hard nproc 16384* soft nofile 1024* hard nofile 65536
core 0表示禁止创建core文件
nproc 128把最多的进程数限制到20
nofile 64表示把一个用户同时打开的最大文件数限制为64
*表示登录到系统的所有用户,不包括root
session required pam_limits.so
10. 修复已知安全漏洞
11. 定期做日志安全检查
/var/log/message– 记录系统日志或当前活动日志
/var/log/auth.log– 身份认证日志
/var/log/cron– Crond 日志 (cron 任务)
/var/log/maillog– 邮件服务器日志
/var/log/secure– 认证日志
/var/log/wtmp历史登录、注销、启动、停机日志和,lastb命令可以查看登录失败的用户
/var/run/utmp当前登录的用户信息日志,w、who命令的信息便来源与此
/var/log/yum.logYum 日志
11.1 安装logwatch
0 0
- CentOS 6服务器简单安全配置
- CentOS 6 服务器安全配置指南
- 通用 CentOS 6 服务器安全配置指南
- 通用 CentOS 6 服务器安全配置指南
- 通用CentOS 6 服务器安全配置指南
- 通用 CentOS 6 服务器安全配置指南
- CentOS服务器安全配置策略
- CentOS 6 的安全配置(CentOS Linux服务器安全设置)
- CentOS 6 的安全配置(CentOS Linux服务器安全设置)
- Centos 5.5服务器的安全配置
- CentOS 5 Web服务器 安全配置
- CentOS 7服务器安全配置(未完待续)
- CentOS 简单安装配置svn服务器
- 简单的CentOS服务器安全配设置(入门篇)
- centos服务器安全
- centos服务器安全设置
- centos服务器安全设置
- CentOS 服务器安全设置
- 第五周项目4数制转换
- serialVersionUID序列化和反序列化的概念
- 11,429种完美的CSS3渐变颜色按钮,图标 代码表
- mybatis+eclipse 逆向工程
- Airbnb是如何创造更好的邮件体验的
- CentOS 6服务器简单安全配置
- Hex文件格式详解
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。Microsoft SQL Server,错误: 10061
- android TextToSpeech 源码分析
- Linux环境变量的设置和查看
- java之异常处理
- window模态导航控制器出现的问题 "whose view is not in the window hierarchy!"
- 求若干整数的最大公约数和最小公倍数
- 二级指针理解 + static的特殊用法