Skip to content

Commit

Permalink
disable ncp user login
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Mar 4, 2018
1 parent 18e35df commit b346cbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
16 changes: 0 additions & 16 deletions etc/nextcloudpi-config.d/SSH.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ 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 "You can change this password from nc-passwd"
echo "SSH disabled"
return 1
}
}

# Enable
chage -d 0 "$USER_"
systemctl enable ssh
Expand Down
5 changes: 3 additions & 2 deletions nextcloudpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ EOF
a2ensite ncp

## NCP USER FOR AUTHENTICATION
useradd $WEBADMIN
echo -e "$WEBPASSWD\n$WEBPASSWD" | passwd $WEBADMIN
useradd --home-dir /nonexistent "$WEBADMIN"
echo -e "$WEBPASSWD\n$WEBPASSWD" | passwd "$WEBADMIN"
chsh -s /usr/sbin/nologin "$WEBADMIN"

## NCP LAUNCHER
mkdir -p /home/www
Expand Down
3 changes: 3 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ EOF
grep -q sleep "$F2BUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$F2BUNIT"
grep -q sleep "$SWPUNIT" || sed -i "/\<start)/asleep 30" "$SWPUNIT"

# disable ncp user login
chsh -s /usr/sbin/nologin ncp

} # end - only live updates

exit 0
Expand Down

0 comments on commit b346cbe

Please sign in to comment.