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}"
# Main
#
main() {
NUM_DEAD=0
KEYCOUNT=0
declare -A KPH
LIST=$( mktemp )
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
K=${KEYHOST[1]}
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
| sort -t: -k2 -k1V \
> $LIST
if [[ $K != "" && $H != $LASTHOST ]]; then
echo " - $H"
LASTHOST=$H
KPH[$H]=$(( ${KPH[$H]} + 1 ))
fi
while IFS=":" read -r -a KEYHOST ; do
K=${KEYHOST[1]}
H=${KEYHOST[0]}
LASTKEY=$K
done
if [[ $K =~ "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
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.
......
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