Skip to content

Instantly share code, notes, and snippets.

#!/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)