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