launch: remove local mode for sshfp records
The "non-local" mode was added to this for the old Bionic based bridge node, whose version of ssh-keyscan didn't have "-D", so we had to actually log into the remote host to query its keys. Now this runs on a Jammy node, we can remove this and just use the remote probe. We don't have to worry about comaptability of this tool, so I've just removed these bits. Change-Id: Ie8254a965597db5695ff1613fc4ebf8cc26f3a25
This commit is contained in:
parent
20d2643f74
commit
8fa64482dd
@ -3,19 +3,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def generate_sshfp_records(hostname, ip, local):
|
def generate_sshfp_records(hostname, ip):
|
||||||
'''Given a hostname and and IP address, scan the IP address (hostname
|
'''Given a hostname and and IP address, scan the IP address (hostname
|
||||||
not in dns yet) and return a bind string with sshfp records'''
|
not in dns yet) and return a bind string with sshfp records'''
|
||||||
|
|
||||||
if local:
|
p = ['ssh-keyscan', '-D', ip]
|
||||||
p = ['ssh-keyscan', '-D', ip]
|
|
||||||
else:
|
|
||||||
# Handle being run via sudo which is the usual way
|
|
||||||
# this is run.
|
|
||||||
p = ['ssh', '-o', 'StrictHostKeyChecking=no',
|
|
||||||
'-i', '/root/.ssh/id_rsa',
|
|
||||||
'root@%s' % ip, 'ssh-keygen', '-r', ip]
|
|
||||||
|
|
||||||
s = subprocess.run(p,
|
s = subprocess.run(p,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE).stdout.decode('utf-8')
|
stderr=subprocess.PIPE).stdout.decode('utf-8')
|
||||||
@ -46,19 +38,17 @@ def generate_sshfp_records(hostname, ip, local):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def sshfp_print_records(hostname, ip, local=False):
|
def sshfp_print_records(hostname, ip):
|
||||||
print(generate_sshfp_records(hostname, ip, local))
|
print(generate_sshfp_records(hostname, ip))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("hostname", help="hostname")
|
parser.add_argument("hostname", help="hostname")
|
||||||
parser.add_argument("ip", help="address to scan")
|
parser.add_argument("ip", help="address to scan")
|
||||||
parser.add_argument("--local", action='store_true',
|
|
||||||
help="Run keyscan locally, rather than via ssh")
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
sshfp_print_records(args.hostname, args.ip, args.local)
|
sshfp_print_records(args.hostname, args.ip)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user