From 2aa0e8f0d48d0c6cae0989bfbff717c21c48e199 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 27 Jun 2018 17:46:18 +0200 Subject: SSH: fix root password in Raspbian --- etc/ncp-config.d/SSH.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'etc') diff --git a/etc/ncp-config.d/SSH.sh b/etc/ncp-config.d/SSH.sh index cbf72263..0693753f 100644 --- a/etc/ncp-config.d/SSH.sh +++ b/etc/ncp-config.d/SSH.sh @@ -53,14 +53,16 @@ configure() local SHADOW="$( grep -E '^pi:' /etc/shadow )" test -n "${SHADOW}" && { local SALT=$(echo "${SHADOW}" | sed -n 's/pi:\$6\$//;s/\$.*//p') - local HASH=$(mkpasswd -msha-512 raspberry "$SALT") - grep -q "${HASH}" <<< "${SHADOW}" && { - systemctl stop ssh - systemctl disable ssh - echo "The user pi is using the default password. Refusing to activate SSH" - echo "SSH disabled" - return 1 + [[ "${SALT}" != "" ]] && { + local HASH=$(mkpasswd -msha-512 raspberry "$SALT") + grep -q "${HASH}" <<< "${SHADOW}" && { + systemctl stop ssh + systemctl disable ssh + echo "The user pi is using the default password. Refusing to activate SSH" + echo "SSH disabled" + return 1 + } } } @@ -68,14 +70,16 @@ configure() local SHADOW="$( grep -E '^root:' /etc/shadow )" test -n "${SHADOW}" && { local SALT=$(echo "${SHADOW}" | sed -n 's/root:\$6\$//;s/\$.*//p') - local HASH=$(mkpasswd -msha-512 1234 "$SALT") - grep -q "${HASH}" <<< "${SHADOW}" && { - systemctl stop ssh - systemctl disable ssh - echo "The user root is using the default password. Refusing to activate SSH" - echo "SSH disabled" - return 1 + [[ "${SALT}" != "" ]] && { + local HASH=$(mkpasswd -msha-512 1234 "$SALT") + grep -q "${HASH}" <<< "${SHADOW}" && { + systemctl stop ssh + systemctl disable ssh + echo "The user root is using the default password. Refusing to activate SSH" + echo "SSH disabled" + return 1 + } } } -- cgit v1.2.3