2017-05-27 18:09:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# credit to the folks at raspberry pi foundatioon
|
|
|
|
check_hash ()
|
|
|
|
{
|
2017-06-09 23:25:56 +00:00
|
|
|
if ! id -u iiab-admin > /dev/null 2>&1 ; then return 0 ; fi
|
2017-05-27 18:09:50 +00:00
|
|
|
if grep -q "^PasswordAuthentication\s*no" /etc/ssh/sshd_config ; then return 0 ; fi
|
2017-06-09 23:25:56 +00:00
|
|
|
SHADOW="$(sudo -n grep -E '^iiab-admin:' /etc/shadow 2>/dev/null)"
|
2017-05-27 18:09:50 +00:00
|
|
|
test -n "${SHADOW}" || return 0
|
2017-06-09 23:25:56 +00:00
|
|
|
if echo $SHADOW | grep -q "iiab-admin:!" ; then return 0 ; fi
|
2017-05-27 18:09:50 +00:00
|
|
|
SHADOW_PW=$(echo $SHADOW | cut -d: -f2)
|
2017-08-31 17:07:05 +00:00
|
|
|
if [ "$SHADOW_PW" != '{{ iiab_admin_passw_hash }}' ]; then return 0 ; fi
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
echo
|
2017-06-09 23:25:56 +00:00
|
|
|
echo "SSH is enabled and the default password for the 'iiab-admin' user is unchanged."
|
|
|
|
echo "This is a security risk - please login as the 'iiab-admin' user and type 'passwd' to change password."
|
2017-05-27 18:09:50 +00:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2017-05-29 16:06:09 +00:00
|
|
|
systemctl is-active {{ sshd_service }} > /dev/null && check_hash
|
2017-05-27 18:09:50 +00:00
|
|
|
unset check_hash
|