Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add port conn params#127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
demonolock wants to merge11 commits intomaster
base:master
Choose a base branch
Loading
fromadd-port-conn-params
Open
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add StrictHostKeyChecking=no for ssh connect
  • Loading branch information
vshepard committedJun 6, 2024
commitdc775c20df12e5ad4383bbe551cf2964d72c2bd6
18 changes: 3 additions & 15 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,15 +48,13 @@ def __init__(self, conn_params: ConnectionParams):
self.host = conn_params.host
self.ssh_key = conn_params.ssh_key
self.port = conn_params.port
self.ssh_cmd = ["-o StrictHostKeyChecking=no"]
if self.ssh_key:
self.ssh_cmd = ["-i", self.ssh_key]
else:
self.ssh_cmd = []
self.ssh_cmd += ["-i", self.ssh_key]
if self.port:
self.ssh_cmd = ["-p", self.port]
self.ssh_cmd+= ["-p", self.port]
self.remote = True
self.username = conn_params.username or self.get_user()
self.add_known_host(self.host)
self.tunnel_process = None

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

def add_known_host(self, host):
known_hosts_path = os.path.expanduser("~/.ssh/known_hosts")
cmd = 'ssh-keyscan -H %s >> %s' % (host, known_hosts_path)

try:
subprocess.check_call(cmd, shell=True)
logging.info("Successfully added %s to known_hosts." % host)
except subprocess.CalledProcessError as e:
raise Exception("Failed to add %s to known_hosts. Error: %s" % (host, str(e)))

def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None,
stderr=None, get_process=None, timeout=None):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp