mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-26 07:15:07 +02:00
Create a host ID by using SSH keys, when possible
This commit is contained in:
parent
2f9b793b78
commit
ebc7cb113e
@ -589,12 +589,33 @@
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create host ID when a MAC address was not found
|
if [ "${HOSTID}" = "" ]; then
|
||||||
#SSH_KEY_FILES="ssh_host_ecdsa_key ssh_host_ecdsa_key.pub ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub"
|
logtext "Result: no HOSTID available, trying to use SSH key as unique source"
|
||||||
#for I in ${SSH_KEY_FILES}; do
|
# Create host ID when a MAC address was not found
|
||||||
#done
|
SSH_KEY_FILES="ssh_host_ecdsa_key ssh_host_ecdsa_key.pub ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub"
|
||||||
|
if [ -d /etc/ssh ]; then
|
||||||
|
for I in ${SSH_KEY_FILES}; do
|
||||||
|
if [ "${HOSTID}" = "" ]; then
|
||||||
|
if [ -f /etc/ssh/${I} ]; then
|
||||||
|
logtext "Result: found ${I} in /etc/ssh"
|
||||||
|
if [ ! "${SHA1SUMBINARY}" = "" ]; then
|
||||||
|
HOSTID=`cat /etc/ssh/${I} | ${SHA1SUMBINARY} | awk '{ print $1 }'`
|
||||||
|
logtext "result: Created HostID with SSH key ($I): ${HOSTID}"
|
||||||
|
else
|
||||||
|
ReportException "GetHostID" "Can't create HOSTID with SSH key, as sha1sum binary is missing"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
logtext "Result: no /etc/ssh directory found, skipping"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show an exception if no HostID could be created, to ensure each system (and scan) has one
|
||||||
|
if [ "${HOSTID}" = "" ]; then
|
||||||
|
ReportException "GetHostID" "No unique host identifier could be created."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Insert section block
|
# Insert section block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user