You are browsing a read-only backup copy of Wikitech. The live site can be found at

Help:SSH Fingerprints

From Wikitech-static
Revision as of 20:05, 10 October 2015 by imported>Alex Monk (example script to generate these pages)
Jump to navigation Jump to search

To find this information, locally you can just run this:

for file in /etc/ssh/*; do ssh-keygen -lf $file; done

Remotely (and to format it for these pages), something like this should work:

import sys
if len(sys.argv) == 0:
	print('Must specify hostname')
hostname = sys.argv[1]
port = 22
if len(sys.argv) > 2:
	port = sys.argv[2]

import subprocess, tempfile
with tempfile.NamedTemporaryFile() as tf:
	keyscanCommand = 'ssh-keyscan', '-t', 'rsa,ecdsa,ed25519', '-p', str(port), hostname, stdout = tf.file, stderr = open('/dev/null'))
	keygenProcess = subprocess.Popen(['ssh-keygen', '-l', '-f',], stdout = subprocess.PIPE)
	stdout, stderr = keygenProcess.communicate()
	for line in stdout.decode('ascii').splitlines():
		bitlen, fingerprint, hostname, type = line.split(' ')
		print(type[1:-1] + ':  <code>' + fingerprint + '</code>\n')