mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-29 21:51:31 +00:00
[Update] 修复测试网关连接known_host问题
This commit is contained in:
@@ -51,7 +51,6 @@ def test_gateway_connectability(gateway):
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
proxy = paramiko.SSHClient()
|
||||
proxy.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
|
||||
proxy.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
|
||||
try:
|
||||
|
||||
@@ -86,6 +86,7 @@ class JMSInventory(BaseInventory):
|
||||
gateway = asset.domain.random_gateway()
|
||||
proxy_command_list = [
|
||||
"ssh", "-p", str(gateway.port),
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"{}@{}".format(gateway.username, gateway.ip),
|
||||
"-W", "%h:%p", "-q",
|
||||
]
|
||||
@@ -97,7 +98,7 @@ class JMSInventory(BaseInventory):
|
||||
if gateway.private_key:
|
||||
proxy_command_list.append("-i {}".format(gateway.private_key_file))
|
||||
|
||||
proxy_command = "'-o ProxyCommand={}'".format(
|
||||
proxy_command = "'-o ProxyCommand={}".format(
|
||||
" ".join(proxy_command_list)
|
||||
)
|
||||
return {"ansible_ssh_common_args": proxy_command}
|
||||
|
||||
Reference in New Issue
Block a user