Unverified Commit bcd0b053 authored by 老广's avatar 老广 Committed by GitHub

[Update] 修改ssh host key生成策略 (#172)

parent 2bfc4b5c
...@@ -8,6 +8,7 @@ import time ...@@ -8,6 +8,7 @@ import time
import threading import threading
import json import json
import signal import signal
import copy
from .conf import config from .conf import config
from .sshd import SSHServer from .sshd import SSHServer
...@@ -59,10 +60,13 @@ class Coco: ...@@ -59,10 +60,13 @@ class Coco:
@ignore_error @ignore_error
def load_extra_conf_from_server(): def load_extra_conf_from_server():
configs = app_service.load_config_from_server() configs = app_service.load_config_from_server()
config.update(configs)
tmp = copy.deepcopy(configs)
tmp['HOST_KEY'] = tmp['HOST_KEY'][32:50] + '...'
logger.debug("Loading config from server: {}".format( logger.debug("Loading config from server: {}".format(
json.dumps(configs) json.dumps(tmp)
)) ))
config.update(configs)
def keep_load_extra_conf(self): def keep_load_extra_conf(self):
def func(): def func():
......
...@@ -31,7 +31,11 @@ class SSHServer: ...@@ -31,7 +31,11 @@ class SSHServer:
def host_key(self): def host_key(self):
host_key_path = os.path.join(config['ROOT_PATH'], 'keys', 'host_rsa_key') host_key_path = os.path.join(config['ROOT_PATH'], 'keys', 'host_rsa_key')
if not os.path.isfile(host_key_path): if not os.path.isfile(host_key_path):
self.gen_host_key(host_key_path) if config.HOST_KEY:
with open(host_key_path, 'w') as f:
f.write(config.HOST_KEY)
else:
self.gen_host_key(host_key_path)
return paramiko.RSAKey(filename=host_key_path) return paramiko.RSAKey(filename=host_key_path)
@staticmethod @staticmethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment