mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
优化初始化安装SSH端口识别
This commit is contained in:
@@ -108,6 +108,7 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
||||
* 使用mariadb二进制导入备份文件
|
||||
* docker插件-镜像导入导出功能
|
||||
* 网站设置反向代理升级功能
|
||||
* 优化初始化安装SSH端口识别
|
||||
|
||||
### JSDelivr安装地址
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ from flask import redirect
|
||||
|
||||
def init():
|
||||
initDB()
|
||||
initDBSshPort()
|
||||
initUserInfo()
|
||||
initInitD()
|
||||
initInitTask()
|
||||
@@ -62,6 +63,19 @@ def initDB():
|
||||
print(str(ex))
|
||||
|
||||
|
||||
def initDBSshPort():
|
||||
# SSH端口必须放开
|
||||
import firewall_api
|
||||
ssh_port = mw.execShell(
|
||||
"cat /etc/ssh/sshd_config | grep 'Port \d*' | tail -1")
|
||||
ssh_port = ssh_port.replace("Port ", '')
|
||||
|
||||
if ssh_port == '':
|
||||
firewall_api.firewall_api().addAcceptPortArgs(22, 'SSH端口', 'port')
|
||||
else:
|
||||
firewall_api.firewall_api().addAcceptPortArgs(ssh_port, 'SSH端口', 'port')
|
||||
|
||||
|
||||
def doContentReplace(src, dst):
|
||||
content = mw.readFile(src)
|
||||
content = content.replace("{$SERVER_PATH}", mw.getRunDir())
|
||||
|
||||
@@ -46,9 +46,8 @@ CREATE TABLE IF NOT EXISTS `firewall` (
|
||||
|
||||
INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES
|
||||
(1, '80', '网站默认端口', '0000-00-00 00:00:00'),
|
||||
(2, '22', 'SSH远程管理服务', '0000-00-00 00:00:00'),
|
||||
(3, '443', 'HTTPS', '0000-00-00 00:00:00'),
|
||||
(4, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00');
|
||||
(2, '443', 'HTTPS', '0000-00-00 00:00:00'),
|
||||
(3, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ dnf install -y crontabs
|
||||
dnf install -y mysql-devel
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -22,6 +22,10 @@ yum install -y mysql-devel
|
||||
yum install -y expect
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -55,6 +55,10 @@ echo y | pacman -Syu icu
|
||||
hwclock --systohc
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -26,8 +26,14 @@ fi
|
||||
ntpdate $NTPHOST | logger -t NTP
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
|
||||
|
||||
# choose lang cmd
|
||||
# dpkg-reconfigure --frontend=noninteractive locales
|
||||
if [ ! -f /usr/sbin/locale-gen ];then
|
||||
|
||||
@@ -18,6 +18,10 @@ yum install -y expect
|
||||
dnf install crontabs -y
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -40,6 +40,10 @@ pkg install -y harfbuzz
|
||||
pkg autoremove -y
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -53,6 +53,10 @@ zypper install -y freetype2-devel
|
||||
# zypper install -y php-config
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/iptables ];then
|
||||
|
||||
@@ -48,6 +48,10 @@ if [ ! -d /root/.acme.sh ];then
|
||||
fi
|
||||
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# redhat , iptables no default
|
||||
|
||||
@@ -24,8 +24,11 @@ apt install -y locate
|
||||
locale-gen en_US.UTF-8
|
||||
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
|
||||
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config |grep Port | grep 22| tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
if [ "$SSH_PORT" == "" ];then
|
||||
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
|
||||
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
|
||||
fi
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
if [ -f /usr/sbin/ufw ];then
|
||||
|
||||
Reference in New Issue
Block a user