Skip to content

Commit 9c251a4

Browse files
author
vshepard
committed
Add StrictHostKeyChecking=no for ssh connect
1 parent fb8f342 commit 9c251a4

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
readme = f.read()
2828

2929
setup(
30-
version='1.10.0',
30+
version='1.10.4',
3131
name='testgres',
3232
packages=['testgres', 'testgres.operations', 'testgres.helpers'],
3333
description='Testing utility for PostgreSQL and its extensions',

testgres/operations/remote_ops.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ def __init__(self, conn_params: ConnectionParams):
4646
self.host = conn_params.host
4747
self.ssh_key = conn_params.ssh_key
4848
self.port = conn_params.port
49+
self.ssh_cmd = ["-o StrictHostKeyChecking=no"]
4950
if self.ssh_key:
50-
self.ssh_cmd = ["-i", self.ssh_key]
51-
else:
52-
self.ssh_cmd = []
51+
self.ssh_cmd += ["-i", self.ssh_key]
5352
if self.port:
54-
self.ssh_cmd = ["-p", self.port]
53+
self.ssh_cmd += ["-p", self.port]
5554
self.remote = True
5655
self.username = conn_params.username or self.get_user()
57-
self.add_known_host(self.host)
5856
self.tunnel_process = None
5957

6058
def __enter__(self):
@@ -78,16 +76,6 @@ def close_ssh_tunnel(self):
7876
else:
7977
print("No active tunnel to close.")
8078

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

0 commit comments

Comments
 (0)