From 5579d3f0ded5329059c35a21cc06d22bfdafc239 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 8 Jun 2018 18:28:15 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=BD=91=E5=85=B3=E8=BF=9E=E6=8E=A5known=5Fhost=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/utils.py | 1 - apps/ops/inventory.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/assets/utils.py b/apps/assets/utils.py index 367c5e5f7..cc4942ade 100644 --- a/apps/assets/utils.py +++ b/apps/assets/utils.py @@ -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: diff --git a/apps/ops/inventory.py b/apps/ops/inventory.py index 6230e8167..230af9dfe 100644 --- a/apps/ops/inventory.py +++ b/apps/ops/inventory.py @@ -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}