Bugfix for invalid keys-check

This commit is contained in:
Christian 2016-03-31 16:00:53 +02:00
parent fe2b275779
commit 7326d8f70d

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
@ -22,10 +22,11 @@ do
find "${dest}/keys" -name '*.pub' | sort | \
while read keyfile
do
valid_key=$(ssh-keygen -l -f ${keyfile})
if [ "$?" -eq "0" ]; then
if [ $(echo "${valid_key}" | cut -d" " -f1) -lt "4096" ]; then
echo "Size of key ${keyfile} is less than 4096. Not adding it to key database." >&2
ssh-keygen -l -f ${keyfile} &> /dev/null
if [ $? -eq 0 ]; then
key_length=`ssh-keygen -l -f ${keyfile} | cut -d" " -f1`
if [ ${key_length} -lt 4096 ]; then
echo "Key size of key ${keyfile} not equal to 4096. Not adding it to key database." >&2
continue
fi
fi