Skip to content

Instantly share code, notes, and snippets.

@0x3333
Created March 9, 2021 15:20
Show Gist options
  • Save 0x3333/85b51aca705b0d557e04878ea07803a7 to your computer and use it in GitHub Desktop.
Save 0x3333/85b51aca705b0d557e04878ea07803a7 to your computer and use it in GitHub Desktop.
Show fingerprints of SSH authorized keys

This scripts shows all fingerprints of SSH authorized keys for the root user.

This is usefull when you are checking which key has been accepted in the /var/log/auth.log.

Like:

Mar  9 10:13:08 hnm sshd[1595179]: Accepted publickey for root from 192.168.1.1 port 56726 ssh2: ED25519 SHA256:OLcfsyZasQWbXze7TVirQd42O09YB704i1N8pKOuve5u
# listkeys
256 SHA256:OLcfsyZasQWbXze7TVirQd42O09YB704i1N8pKOuve5u user1@remote-pc1 (ED25519)
256 SHA256:yNVs4yYt1IRV7jRh0PteYmZ0i7PgKUNJJGbgIbJLGIgm user2@remote-pc2 (ED25519)
256 SHA256:6CoCJaSmKLQ9vSgBhz8XH8vjXx8XVIFCOUA9wdJbd6L1 user3@remote-pc3 (ED25519)
256 SHA256:0QYFc7OiUnbOJlpuAsbvIN7KniahUMUmCO2ztZehJ50d user4@remote-pc4 (ED25519)
#!/bin/bash
cat /root/.ssh/authorized_keys | while read ln
do
if [ ! -z "$ln" ]; then
echo $ln | ssh-keygen -lf -
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment