From e8c636a2337d07cb4bd5a7005f738af7567c4fb2 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Mon, 21 Dec 2020 17:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/init.sh b/init.sh index ddd6636..162f3e7 100644 --- a/init.sh +++ b/init.sh @@ -3,6 +3,7 @@ #同步时间 function sync_time() { + echo '正在执行时间同步......' yum -y install ntpdate #设置时区 timedatectl set-local-rtc 1 @@ -15,9 +16,23 @@ function sync_time() { systemctl reload crond echo "同步成功,当前时间:" `date` } - +#修改SSH端口 +function change_port() { + echo '正在修改SSH端口......' + config_file="/etc/ssh/sshd_config" + if grep -q "^Port" $config_file;then + sed -i "/^Port/c Port 1993" $config_file + else + echo "Port 1993" >> $config_file + fi + systemctl restart sshd + firewall-cmd --zone=public --add-port=1993/tcp --permanent + firewall-cmd --reload + echo 'SSH端口修改完毕......' +} #安装BBR function insrall_bbr() { + echo '正在安装BBR......' yum -y install wget wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm --import RPM-GPG-KEY-elrepo.org @@ -34,7 +49,9 @@ function insrall_bbr() { #清理工作 rm -rf RPM-GPG-KEY-elrepo.org bbr.sh + echo 'BBR安装完毕,10s后重启...' + sleep 10 #重启服务器 reboot } -sync_time && insrall_bbr \ No newline at end of file +sync_time && change_port && insrall_bbr \ No newline at end of file