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

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

parent 2bfc4b5c
......@@ -8,6 +8,7 @@ import time
import threading
import json
import signal
import copy
from .conf import config
from .sshd import SSHServer
......@@ -59,10 +60,13 @@ class Coco:
@ignore_error
def load_extra_conf_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(
json.dumps(configs)
json.dumps(tmp)
))
config.update(configs)
def keep_load_extra_conf(self):
def func():
......
......@@ -31,7 +31,11 @@ class SSHServer:
def host_key(self):
host_key_path = os.path.join(config['ROOT_PATH'], 'keys', 'host_rsa_key')
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)
@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