Skip to content

Commit dc775c2

Browse files
author
vshepard
committed
Add StrictHostKeyChecking=no for ssh connect
1 parent 80ba614 commit dc775c2

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

testgres/operations/remote_ops.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ def __init__(self, conn_params: ConnectionParams):
4848
self.host = conn_params.host
4949
self.ssh_key = conn_params.ssh_key
5050
self.port = conn_params.port
51+
self.ssh_cmd = ["-o StrictHostKeyChecking=no"]
5152
if self.ssh_key:
52-
self.ssh_cmd = ["-i", self.ssh_key]
53-
else:
54-
self.ssh_cmd = []
53+
self.ssh_cmd += ["-i", self.ssh_key]
5554
if self.port:
56-
self.ssh_cmd = ["-p", self.port]
55+
self.ssh_cmd += ["-p", self.port]
5756
self.remote = True
5857
self.username = conn_params.username or self.get_user()
59-
self.add_known_host(self.host)
6058
self.tunnel_process = None
6159

6260
def __enter__(self):
@@ -80,16 +78,6 @@ def close_ssh_tunnel(self):
8078
else:
8179
print("No active tunnel to close.")
8280

83-
def add_known_host(self, host):
84-
known_hosts_path = os.path.expanduser("~/.ssh/known_hosts")
85-
cmd = 'ssh-keyscan -H %s >> %s' % (host, known_hosts_path)
86-
87-
try:
88-
subprocess.check_call(cmd, shell=True)
89-
logging.info("Successfully added %s to known_hosts." % host)
90-
except subprocess.CalledProcessError as e:
91-
raise Exception("Failed to add %s to known_hosts. Error: %s" % (host, str(e)))
92-
9381
def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
9482
encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None,
9583
stderr=None, get_process=None, timeout=None):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy