【综合架构】Part 0.2 模板机基础优化

基础优化

1、系统安全

systemctl stop firewalld.service
systemctl disable firewalld.service

setenforce 0
sed -i '7s#enforcing#disable#g' /etc/selinux/config

2、源与常用工具

# 配置yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 常用工具
yum install -y vim tree wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telent bc psmisc httpd-tools bind-utils nethogs expect cowsay sl ntpdate xorg-x11-xauth sl cowsay

# epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

3、时间同步

# 查看时区
timedatectl status

# 安装ntpdate
yum install -y ntpdate

# 设置时区
timedatectl set-timezone Asia/Shanghai

# 设置定时任务,每 2 分钟执行一次
crontab -e
# 文本输入以下信息:
#1. sync time
*/2 * * * * /sbin/ntpdate ntp1.aliyun.com &>/dev/null

4、远程连接

sed -ri '$aGSSAPIAuthentication no\nUseDNS no' /etc/ssh/sshd_config
systemctl restart sshd

# 查看修改结果
egrep '^(UseDNS|GSSAPI)' /etc/ssh/sshd_config

# 假如进行上述配置后,无法ssh连接,进行以下操作即可。
sed -i '79d;115d' /etc/ssh/sshd_config

5、修改主机名

 hostnamectl set-hostname template

6、脚本

一键修改主机名和ip地址的脚本basic.sh

【Shell脚本】一键配置主机名和ip地址-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值