Skip to content

Commit 30c34d8

Browse files
committed
SSH: enhance security
1 parent 36bb1de commit 30c34d8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
[v0.41.2](https://github.com/nextcloud/nextcloudpi/commit/f4dd242) (2017-12-04) nc-automount: check for USBdrive labeled drive case
2+
[v0.41.3](https://github.com/nextcloud/nextcloudpi/commit/bf1ff0e) (2017-12-05) SSH: enhance security
3+
4+
[v0.41.2 ](https://github.com/nextcloud/nextcloudpi/commit/a2c5de7) (2017-12-04) nc-automount: check for USBdrive labeled drive case
35

46
[v0.41.1 ](https://github.com/nextcloud/nextcloudpi/commit/9ef8bc1) (2017-12-04) nc-info: warn of long operation
57

etc/nextcloudpi-config.d/SSH.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ configure()
3939
id "$USER_" &>/dev/null || useradd "$USER_"
4040
echo -e "$PASS_\n$CONFIRM_" | passwd "$USER_" || return 1
4141

42-
# Check for insecure default password ( taken from old jessie method )
42+
# Check for insecure default pi password ( taken from old jessie method )
4343
local SHADOW="$( grep -E '^pi:' /etc/shadow )"
4444
test -n "${SHADOW}" && {
4545
local SALT=$(echo "${SHADOW}" | sed -n 's/pi:\$6\$//;s/\$.*//p')
@@ -54,7 +54,23 @@ configure()
5454
}
5555
}
5656

57+
# Check for insecure default ncp password ( taken from old jessie method )
58+
local SHADOW="$( grep -E '^ncp:' /etc/shadow )"
59+
test -n "${SHADOW}" && {
60+
local SALT=$(echo "${SHADOW}" | sed -n 's/ncp:\$6\$//;s/\$.*//p')
61+
local HASH=$(mkpasswd -msha-512 ownyourbits "$SALT")
62+
63+
grep -q "${HASH}" <<< "${SHADOW}" && {
64+
systemctl stop ssh
65+
systemctl disable ssh
66+
echo "The user ncp is using the default password. Refusing to activate SSH"
67+
echo "SSH disabled"
68+
return 1
69+
}
70+
}
71+
5772
# Enable
73+
chage -d 0 "$USER_"
5874
systemctl enable ssh
5975
systemctl start ssh
6076
echo "SSH enabled"

0 commit comments

Comments
 (0)