From a4b723817a29246d168bed40476245e56ea096d4 Mon Sep 17 00:00:00 2001 From: xiaoz Date: Wed, 9 Aug 2017 17:59:25 +0800 Subject: [PATCH] update --- security.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 security.sh diff --git a/security.sh b/security.sh new file mode 100644 index 0000000..abd67ce --- /dev/null +++ b/security.sh @@ -0,0 +1,22 @@ +#!/bin/bash +########## 安全设置脚本 ########## + +read -p "修改主机名(留空则不修改,请直接回车):" myhostname +read -p "修改SSH端口:" sshport + +if [ "$myhostname" != '' ] +then + sudo hostnamectl set-hostname ${myhostname} +if [ "$sshport" != '' ] + then + #删除SSH端口 + sed -i '/^#Port/'d /etc/ssh/sshd_config + sed -i '/^Port/'d /etc/ssh/sshd_config + #添加端口 + sed -i "/^#AddressFamily/i\Port ${sshport}" /etc/ssh/sshd_config + #重载服务 + service sshd restart + echo "修改完成." +else + exit +fi \ No newline at end of file