系统安装后那些该做的事(centos6.x)

iptables防火墙

一般先关了吧,需要的时候再按需求开启相应的。

/etc/init,d/iptables stop
chkconfig iptables off

SELinux

听说很强大,但是我们没用,还是关了吧。

setenforce 0     #临时关闭
getenforce       #查看
#永久关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

运行级别

通常我们用文本命令行模式,运行级别为3,有桌面的话运行级别为5。

runlevel         #查看运行级别
init 运行级别     #修改运行级别
/etc/inittab     #配置文件

精简开机自启动软件

除了sshd、rsyslog、network、crond和sysstat服务必须保留,其它皆可关闭。
需要其他服务也可以按需开启。

chkconfig --list | grep 3:on | grep -vE "crond|sshd|network|rsyslog|sysstat" | awk '{print "chkconfig" $1 "off"}' | bash

修改SSH服务配置

修改ssh服务的端口和连接配置

vim /etc/ssh/sshd_config    # 最好先备份
Port 10022
PermitRootLogin no
PermitEmptyPasswords no
UseDNS no
GSSAPIAuthentication no

/etc/init.d/sshd reload
以上五项配置分别为:
修改端口号
禁止密码为空的用户远程登录
禁止root用户登录
不对远程主机名进行反向解析
解决连接慢的问题

设置安装源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

注:内网环境请创建本地源:

vim /etc/yum.repos.d/Centos6.repo

[Centos6]
name = Centos6
baseurl=file:///mnt/
gpgcheck=0
enabled=1

mount /dev/cdrom /mnt

安装常用工具

yum -y install lrzsz nmap tree vim dos2unix nc telnet

升级典型具有漏洞的软件版本

yum -y install openssl openssh bash

创建普通用户管理系统

创建普通用户,进行相应的授权,利用sudo命令使普通用户拥有相应的权限。
略。。。

字符集(可选)

我选择的是支持中文的字符集

echo 'LANG="zh_CN.UTF-8"' >/etc/sysconfig/i18n
source /etc/sysconfig/i18n
echo $LANG

时间同步

echo '*/5 * * * * /usr/sbin/ntpdate 时间服务器 >/dev/null 2>&1' >>/var/spool/cron/root

注:服务器少的时候可以使用这种方法,多的话最好搭建一台时间服务器。

重要文件加锁

chattr +i /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab

注:解锁参数为“-i”

… …
7版本的只有个别地方差异,就不写了,问的话留言。

哇,看到的能不能顺便点个赞啊,升级实在是太慢了。。。

猜你喜欢

转载自blog.csdn.net/qq_42527269/article/details/106771789