You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
790 B
Python
27 lines
790 B
Python
5 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
import argparse
|
||
|
from pathlib import Path
|
||
|
import subprocess
|
||
|
import sys
|
||
|
|
||
|
def gen_sshfp_rr(keys_dir, host, domain):
|
||
|
key_dir = Path(keys_dir) / host
|
||
|
res = []
|
||
|
for key in key_dir.iterdir():
|
||
|
if key.name != "dns":
|
||
|
res.append(subprocess.check_output(["ssh-keygen", "-r", domain, "-f", str(key)]).decode('utf-8').strip())
|
||
|
return '\n'.join(res)
|
||
|
|
||
|
def main():
|
||
|
ssh_hosts_keys = Path(sys.argv[0]).parent / "ssh/hosts"
|
||
|
parser = argparse.ArgumentParser()
|
||
|
parser.add_argument('--domain', default=None)
|
||
|
parser.add_argument('--host', required=True)
|
||
|
args = parser.parse_args()
|
||
|
args.domain = (args.domain or args.host) + "."
|
||
|
print(gen_sshfp_rr(ssh_hosts_keys, args.host, args.domain))
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|