Created
December 3, 2021 12:42
-
-
Save hboetes/50aa2cdd1e64003d6cac966baae96da4 to your computer and use it in GitHub Desktop.
findunsecuredsshkeys
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/sh | |
for dir in $(getent passwd|awk -F : '{print $6}'); do | |
if [ ! -d $dir/.ssh ]; then | |
continue | |
fi | |
find $dir/.ssh -type f | while read file; do | |
if ! file "$file" | grep -iq 'private key'; then | |
continue | |
fi | |
if ssh-keygen -P '' -y -f "$file" > /dev/null 2>&1; then | |
echo "Unsecured ssh private key found! $file" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This scriptlet can find unencrypted private ssh keys.