1.关闭不需要的服务(crond,network,rsyslog,sshd,sysstat)
\]# setup
2.创建最小权限用户 /etc/sudoers 或者使用 visudo
\]# useradd moxiang
\]# echo "111111" | passwd --stdin test
\]# visudo
test ALL=(ALL) ALL 添加,表示当执行某些命令时,使用sudo COMMOND 加自己密码
3.关闭iptables ,ipv6 (或者创建/etc/modprobe/ipv6disable.conf)
\]# vim /etc/modprobe/dist.conf 关闭ipv6,最后追加
alias net-pf-10 off
alias ipv6 off
\]# chkconfig --level 3 iptables off
\]# chkconfig --list |grep iptables
iptables 0:off1:off2:on3:off4:on5:off6:off
4.关闭selinux
\]# vim /etc/selinux/config
SELINUX=enforcing 改为 permissive或disabled
5.语言为英文
\]# vim /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
6.文件描述符修改 /etc/security/limits.d目录下
]# vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
7.开启时间服务
\]# yum install ntp -y
\]# service ntpd start
Starting ntpd: [ OK ]
]# chkconfig --level 35 ntpd on
8.安装程序包
\]# yum groupinstall "Base" "Development tools"
9.配置sudo的日志文件
(1)创建日志文件 sudo.log
touch /var/log/sudo.log
(2)修改/etc/rsyslog.conf配置文件
vim /etc/rsyslog.conf 结尾增加,空白部分用“TAB”键
local2.debug /var/log/sudo.log
(3)重启rsyslog 服务
/etc/init.d/syslog restart
测试:可以在/var/log/sudo.log中看到普通用户使用sudo执行的操作
10.修改SSH端口号和屏蔽root账号远程登陆
#备份SSH配置
cp /etc/ssh/sshd_config sshd_config_bak
#修改SSH安全配置
vi /etc/ssh/sshd_config
#SSH链接默认端口
port 52113
#禁止root账号登陆
PermitRootLogin no
#禁止空密码
PermitEmptyPasswords no
#不使用DNS
UseDNS no
11.创建yum仓库;
wget mirrors.aliyun.com/repo/Centos-6.repo
yum clean all
yum makecache
# vim epel.repo
[epel]
name=epel
baseurl=http://mirrors.aliyun.com/epel/6Server/x86_64/
enabled=1
gpgcheck=0