Created
February 5, 2019 11:55
-
-
Save SharkyRawr/d4842eba1c585299d219325ee58f445f to your computer and use it in GitHub Desktop.
Convert OpenSSH authorized_keys entries in to sha256 sums used in /var/log/auth.log
This file contains 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
#! /bin/bash -ex | |
while read p; do | |
echo -e "\n$p ->" | |
echo $p | awk '{ print $2 }' | # Only the actual key data without prefix or comments | |
base64 -d | # decode as base64 | |
sha256sum | # SHA256 hash (returns hex) | |
awk '{ print $1 }' | # only the hex data | |
xxd -r -p | # hex to bytes | |
base64 # encode as base64 | |
done < /root/.ssh/authorized_keys | |
# thanks to https://serverfault.com/a/888300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment