Commit 470d3aff authored by Michael Völske's avatar Michael Völske

update authorized-ssh-keys

parent 7cdf3f1b
...@@ -38,34 +38,37 @@ eval set -- "${FLAGS_ARGV}" ...@@ -38,34 +38,37 @@ eval set -- "${FLAGS_ARGV}"
# Main # Main
# #
main() { main() {
NUM_DEAD=0 NUM_DEAD=0
KEYCOUNT=0
declare -A KPH declare -A KPH
LIST=$( mktemp )
salt '*' cmd.run 'find /root /home -path "*/.ssh/authorized_keys" -maxdepth 4 -exec cat \{\} \;' --output=txt \ salt '*' cmd.run 'find /root /home -path "*/.ssh/authorized_keys" -maxdepth 4 -exec cat \{\} \;' --output=txt \
| sort -t: -k2 -k1V | while IFS=":" read -r -a KEYHOST ; do | sort -t: -k2 -k1V \
K=${KEYHOST[1]} > $LIST
H=${KEYHOST[0]}
if [[ $H =~ "Minion did not return" ]]; then
NUM_DEAD=$(( NUM_DEAD + 1))
elif [[ $K != $LASTKEY && $K != "" ]]; then
echo Key: $K
echo Used on hosts:
KEYCOUNT=$(( $KEYCOUNT + 1 ))
LASTHOST=""
fi
if [[ $K != "" && $H != $LASTHOST ]]; then while IFS=":" read -r -a KEYHOST ; do
echo " - $H" K=${KEYHOST[1]}
LASTHOST=$H H=${KEYHOST[0]}
KPH[$H]=$(( ${KPH[$H]} + 1 ))
fi
LASTKEY=$K if [[ $K =~ "did not return" ]]; then
done NUM_DEAD=$(( NUM_DEAD + 1))
elif [[ $K != $LASTKEY && $K != "" ]]; then
echo Key: $K
echo Used on hosts:
KEYCOUNT=$(( $KEYCOUNT + 1 ))
LASTHOST=""
fi
echo "TOTAL UNIQUE KEYS: $KEYCOUNT; $NUM_DEAD hosts offline; ${#KPH[@]} hosts online." if [[ $K != "" && $H != $LASTHOST ]]; then
echo " - $H"
LASTHOST=$H
KPH[$H]=$(( ${KPH[$H]} + 1 ))
fi
LASTKEY=$K
done < $LIST
rm -f $LIST
echo "TOTAL UNIQUE KEYS: $KEYCOUNT; $NUM_DEAD hosts offline; ${#KPH[@]} hosts online."
} }
# #
# Start programm with parameters. # Start programm with parameters.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment