Sort knownhosts entries
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
5250a53078
commit
68433c1e59
1 changed files with 9 additions and 6 deletions
|
@ -54,13 +54,16 @@ def read_and_reduce():
|
||||||
|
|
||||||
def write_hosts_file(knownhosts):
|
def write_hosts_file(knownhosts):
|
||||||
# Replace known hosts with a cleaned version
|
# Replace known hosts with a cleaned version
|
||||||
with open(KNOWN_HOSTS, 'w') as f:
|
lines = []
|
||||||
for key, host in knownhosts.items():
|
for key, host in knownhosts.items():
|
||||||
if len(host['hosts']) == 0:
|
if len(host['hosts']) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
host['hosts_joined'] = ",".join(sorted(host['hosts'], reverse=True))
|
host['hosts_joined'] = ",".join(sorted(host['hosts'], reverse=True))
|
||||||
f.write("{hosts_joined} {keytype} {fingerprint}\n".format(**host))
|
lines.append("{hosts_joined} {keytype} {fingerprint}".format(**host))
|
||||||
|
|
||||||
|
with open(KNOWN_HOSTS, 'w') as f:
|
||||||
|
f.write('\n'.join(sorted(lines)))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue