Opt: Generate random ssh username

This commit is contained in:
18870 2022-07-03 15:45:37 +08:00
parent 4fbefd73c2
commit 297b0267ca
9 changed files with 25 additions and 22 deletions

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -106,16 +106,16 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null
# [Format] host:port
SSHServer: null
# Filepath of SSH executable `ssh.exe`
# [Default] null (use ssh in system PATH)
# [Default] ssh (find ssh in system PATH)
# If you don't have one, install OpenSSH or download it here (https://github.com/PowerShell/Win32-OpenSSH/releases)
SSHExecutable: null
SSHExecutable: ssh
Webui:
# --host. Host to listen

View File

@ -75,7 +75,7 @@ class DeployConfig(ConfigModel):
def show_config(self):
logger.hr("Show deploy config", 1)
for k, v in self.config.items():
if k in ("Password"):
if k in ("Password", "SSHUser"):
continue
if self.config_template[k] == v:
continue

View File

@ -106,7 +106,7 @@ Deploy:
# See here (http://app.azurlane.cloud/en.html) for more infomation.
EnableRemoteAccess: false
# Username when login into ssh server
# [Default] null (use username logged in your system)
# [Default] null (will generate a random one when startup)
SSHUser: null
# Server to connect
# [Default] null

View File

@ -17,6 +17,7 @@ from subprocess import PIPE, Popen
from typing import TYPE_CHECKING
from module.logger import logger
from module.config.utils import random_id
from module.webui.setting import State
if TYPE_CHECKING:
@ -158,9 +159,11 @@ def start_remote_access_service(**kwagrs):
else:
local_host = State.deploy_config.WebuiHost
if State.deploy_config.SSHUser:
server = f"{State.deploy_config.SSHUser}@{server}"
if State.deploy_config.SSHUser is None:
logger.info("SSHUser is not set, generate a random one")
State.deploy_config.SSHUser = random_id(24)
server = f"{State.deploy_config.SSHUser}@{server}"
kwagrs.setdefault("server", server)
kwagrs.setdefault("server_port", server_port)
kwagrs.setdefault("local_host", local_host)