Last active
January 28, 2022 07:45
-
-
Save akase244/2be2cde1481691fbbd3671e942edaa47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/bash | |
awk -F':' '{print $6}' /etc/passwd |sort |uniq | while read line | |
do | |
if [ -e "${line}/.ssh/authorized_keys" ]; then | |
echo ${line} | |
for i in $(seq 1 $(wc -l ${line}/.ssh/authorized_keys |awk '{print $1}')); do | |
sed -n ${i}p ${line}/.ssh/authorized_keys |grep -v -e '^\s*#' -e '^\s*$' |grep -q -e 'ssh-rsa ' -e 'ssh-dsa ' -e 'ssh-dss ' -e 'ssh-ed25519 ' | |
if [ $? -eq 0 ]; then | |
ssh-keygen -l -f <(sed -n ${i}p ${line}/.ssh/authorized_keys) | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment