Last active
August 29, 2015 13:57
-
-
Save cagerton/9441105 to your computer and use it in GitHub Desktop.
Simple script to fetch an ssh host key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
"""Usage: fetch_hostkey.py <host> [<port>]""" | |
import paramiko, docopt | |
opt = docopt.docopt(__doc__) | |
host = opt['<host>'] | |
port = int(opt['<port>'] or 22) | |
t = paramiko.Transport((host, port)) | |
t.connect() | |
k = t.get_remote_server_key() | |
t.close() | |
kh_line = "%s %s %s" % (host, k.get_name(), k.get_base64()) | |
print(kh_line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment