tweaks to reading ssh config

This commit is contained in:
Joshua Tauberer 2024-03-23 09:00:36 -04:00
parent bdda55413c
commit 2a42e888c3
2 changed files with 9 additions and 9 deletions

View File

@ -449,9 +449,10 @@ def build_sshfp_records():
# specify that port to sshkeyscan.
port = get_ssh_port()
# If nothing returned, assume default
# If nothing returned, SSH is probably 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"))

View File

@ -181,7 +181,7 @@ def wait_for_service(port, public, env, timeout):
def get_ssh_port():
port_value = get_ssh_config_value("port")
if port_value:
return int(port_value)
@ -198,12 +198,11 @@ 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:
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