From be7434e6d7ebccc66360f69f2e848df622423679 Mon Sep 17 00:00:00 2001 From: KiekerJan Date: Sat, 23 Mar 2024 15:53:05 +0100 Subject: [PATCH] merge updated ssh parameter function --- management/dns_update.py | 4 ++-- management/utils.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 4dff7423f..57e506e15 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -482,9 +482,9 @@ def build_sshfp_records(): # specify that port to sshkeyscan. port = get_ssh_port() - # If nothing returned, assume default + # If nothing returned, assume ssh not installed if not port: - port = 22 + return keys = shell("check_output", ["ssh-keyscan", "-4", "-t", "rsa,dsa,ecdsa,ed25519", "-p", str(port), "localhost"]) keys = sorted(keys.split("\n")) diff --git a/management/utils.py b/management/utils.py index ebf4185ed..5addde61a 100644 --- a/management/utils.py +++ b/management/utils.py @@ -198,13 +198,12 @@ def get_ssh_config_value(parameter_name): # error while calling shell command return None - returnNext = False - for e in output.split(): - if returnNext: - return e - if e == parameter_name.lower(): - returnNext = True - + for line in output.split("\n"): + if " " not in line: continue # there's a blank line at the end + key, values = line.split(" ", 1) + if key == parameter_name: + return values # space-delimited if there are multiple values + # Did not find the parameter! return None