CentOS VPS入手后的基本优化和安全配置
2014-12-30 14:44
661 查看
适用环境和条件:安装CentOS5或6的任意VPS
升级系统
升级防火墙策略
删除不用的应用
清理不需要的用户和用户组
更新为香港时区
支持zip和unzip
升级系统
yum update
升级防火墙策略
#清除现有防火墙规则 iptables -F iptables -X iptables -Z #允许本机访问本机 iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT # 允许已建立的或相关连的通行 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT</p> <p> #允许有限的ping功能,每秒10次 iptables -A INPUT -p icmp -m limit --limit 10/sec -j ACCEPT</p> <p> #允许所有本机向外的访问 iptables -A OUTPUT -j ACCEPT</p> <p> # 允许访问22端口,默认的SSH端口,请先保留,等修改sshd_conf后再进行修改 iptables -A INPUT -p tcp --dport 22 -j ACCEPT</p> <p> #允许访问80端口 iptables -A INPUT -p tcp --dport 80 -j ACCEPT</p> <p> #允许其他端口只需要修改端口号即可</p> <p> #禁止其他未允许的规则访问 iptables -A INPUT -j REJECT (注意:如果22端口未加入允许规则,SSH链接会直接断开。) iptables -A FORWARD -j REJECT</p> <p>#保持防火墙规则 service iptables save #如果保持失败,是因为缺少policycoreutils,请先安装 yum -y install policycoreutils #之后再进行保存 #将iptables加入随机启动 chkconfig --level 345 iptables on
删除不用的应用
yum remove Deployment_Guide-en-US cups-libs cups bluez-libs desktop-file-utils ppp rp-pppoe wireless-tools irda-utils nfs-utils nfs-utils-lib rdate fetchmail eject ksh mkbootdisk mtools syslinux tcsh startup-notification talk apmd rmt dump setserial portmap yp-tools ypbind #删除不安全的服务 yum remove telnet rsh ftp rcp #安装postfix替代sendmail yum install postfix #删除sendmail yum remove sendmail #禁用和删除xinetd服务 /sbin/service xinetd stop; /sbin/chkconfig xinetd off rm -rf /etc/xinetd.d
清理不需要的用户和用户组
#复制备份一份passwd和group cp /etc/passwd /etc/passwd.sav cp /etc/group /etc/group.sav #删除没用的用户和用户组 for a in adm lp sync news uucp operator games gopher mailnull nscd rpc; do /usr/sbin/userdel $a -f; done for a in lp news uucp games gopher users floopy nscd rpc rpcuser nfsnobody; do /usr/sbin/groupdel $a -f; done
更新为香港时区
ln -sf /usr/share/zoneinfo/Hongkong /etc/localtime
支持zip和unzip
yum install zip unzip
相关文章推荐
- VPS安全之iptables基本配置
- Centos 6.5 服务器优化配置备忘(一些基础优化和安全设置)
- Linux运维二:CentOS6.6系统安装后的基本配置与优化
- VPS安全之iptables基本配置 远离暴力破解
- 基于CentOS系统的VPS安全设置与优化
- CentOS 6.5 x64相关安全,优化配置
- VPS安全之iptables基本配置 远离暴力破解
- VPS安全之iptables基本配置 远离暴力破解
- VPS安全之iptables基本配置 远离暴力破解
- VPS安全之iptables基本配置 远离暴力破解
- 基于CentOS 6.4系统的VPS安全设置与优化
- CentOS系统的VPS安全设置与优化
- CentOS Linux下MySQL 5.1.x的安装、优化和安全配置
- Win2003 + IIS6.0 + PHP5 / ASP + MySQL5 服务器配置及虚拟主机基本安全设置
- FCKeditor基本配置优化修改使用方法
- VPS 配置优化笔记
- Centos安装后基本配置
- FCKeditor基本配置优化修改使用方法
- CentOS下的网络设置--基本配置文件篇