手机
当前位置:查字典教程网 >操作系统 >RedHat/Centos >CentOS VPS入手后的基本优化和安全配置
CentOS VPS入手后的基本优化和安全配置
摘要:适用环境和条件:安装CentOS5或6的任意VPS升级系统yumupdate升级防火墙策略#清除现有防火墙规则iptables-Fiptab...

适用环境和条件:安装CentOS5或6的任意VPS

升级系统

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

【CentOS VPS入手后的基本优化和安全配置】相关文章:

centos 系统下安装配置FastDFS步骤分享

CentOS 6.6系统桌面字体怎么设置?

CentOS VPS新硬盘分区与挂载教程

CentOS VPS如何打开80端口解决网站打不开的问题

linux构建动态WEB服务器安装篇

在CentOS 6.3中安装与配置JDK-7

CentOS中net-snmpd的安装和基本配置教程

CentOS 常用配置方法

CentOS 6.3下Samba服务器的安装与配置方法(图文详解)

用CentOS搭建文件服务器(Samba)

精品推荐
分类导航