How to print fingerprints of all SSH host keys

In oder to print new-style (SHA256) fingerprints such as Is7oLjYcKue/zRjPKy9gQma/9F24KGaMPHbGberPGAw, use

for i in /etc/ssh/ssh_host_*_key; do sudo ssh-keygen -l -E sha256 -f "$i"; done

Example output:

1024 SHA256:SAhM78NWwqoYS/nRByGs1oqJxrX8fZL/PR/F5oX3QWs [email protected] (DSA)
256 SHA256:V/+9872Yg1i2Q4i7Nt4ef5R06lAuzT6qKemaQEt8EJQ [email protected] (ECDSA)
256 SHA256:Is7oLjYcKue/zRjPKy9gQma/9F24KGaMPHbGberPGAw [email protected] (ED25519)
2048 SHA256:AORSBitRPpwXrbTQzP0Mb/OBXyK+V6gyWf0S4bIh7Ys [email protected] (RSA)

In order to print old-style (MD5) fingerprints such as 5c:19:8b:94:44:5e:b6:15:e6:32:cc:3c:9b:38:6b:4c, use this command:

for i in /etc/ssh/ssh_host_*_key; do sudo ssh-keygen -l -E md5 -f "$i"; done

Example output:

1024 MD5:6d:f8:17:9b:4a:f5:ec:14:04:68:22:9c:ca:2c:a1:19 [email protected] (DSA)
256 MD5:5c:19:8b:94:44:5e:b6:15:e6:32:cc:3c:9b:38:6b:4c [email protected] (ECDSA)
256 MD5:45:dd:7f:91:89:67:ab:2d:ee:a2:f8:9e:18:68:5b:0d [email protected] (ED25519)
2048 MD5:1b:b2:54:3a:10:51:17:b4:49:af:73:c2:da:d6:fc:df [email protected] (RSA)