Skip to content

Commit

Permalink
SSH: enhance security
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Dec 5, 2017
1 parent 36bb1de commit 30c34d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

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

[v0.41.2 ](https://github.com/nextcloud/nextcloudpi/commit/a2c5de7) (2017-12-04) nc-automount: check for USBdrive labeled drive case

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

Expand Down
18 changes: 17 additions & 1 deletion etc/nextcloudpi-config.d/SSH.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ configure()
id "$USER_" &>/dev/null || useradd "$USER_"
echo -e "$PASS_\n$CONFIRM_" | passwd "$USER_" || return 1

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

# Check for insecure default ncp password ( taken from old jessie method )
local SHADOW="$( grep -E '^ncp:' /etc/shadow )"
test -n "${SHADOW}" && {
local SALT=$(echo "${SHADOW}" | sed -n 's/ncp:\$6\$//;s/\$.*//p')
local HASH=$(mkpasswd -msha-512 ownyourbits "$SALT")

grep -q "${HASH}" <<< "${SHADOW}" && {
systemctl stop ssh
systemctl disable ssh
echo "The user ncp is using the default password. Refusing to activate SSH"
echo "SSH disabled"
return 1
}
}

# Enable
chage -d 0 "$USER_"
systemctl enable ssh
systemctl start ssh
echo "SSH enabled"
Expand Down

0 comments on commit 30c34d8

Please sign in to comment.