Changed approach for generating sshfp RR to lookup on python script
parent
748999d36d
commit
eff48f1773
@ -1,4 +0,0 @@
|
||||
FILES = $(shell ls | grep -vE "^dns$$")
|
||||
|
||||
dns: $(FILES)
|
||||
echo "$(FILES)" | xargs --max-args 1 ssh-keygen -r "$$(basename "$$(pwd)")." -f > "$@"
|
@ -0,0 +1,26 @@
|
||||
#!/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()
|
Loading…
Reference in New Issue