Skip to content

Commit b346cbe

Browse files
committed
disable ncp user login
1 parent 18e35df commit b346cbe

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

etc/nextcloudpi-config.d/SSH.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@ configure()
5858
}
5959
}
6060

61-
# Check for insecure default ncp password ( taken from old jessie method )
62-
local SHADOW="$( grep -E '^ncp:' /etc/shadow )"
63-
test -n "${SHADOW}" && {
64-
local SALT=$(echo "${SHADOW}" | sed -n 's/ncp:\$6\$//;s/\$.*//p')
65-
local HASH=$(mkpasswd -msha-512 ownyourbits "$SALT")
66-
67-
grep -q "${HASH}" <<< "${SHADOW}" && {
68-
systemctl stop ssh
69-
systemctl disable ssh
70-
echo "The user ncp is using the default password. Refusing to activate SSH"
71-
echo "You can change this password from nc-passwd"
72-
echo "SSH disabled"
73-
return 1
74-
}
75-
}
76-
7761
# Enable
7862
chage -d 0 "$USER_"
7963
systemctl enable ssh

nextcloudpi.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ EOF
9494
a2ensite ncp
9595

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

100101
## NCP LAUNCHER
101102
mkdir -p /home/www

update.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ EOF
244244
grep -q sleep "$F2BUNIT" || sed -i "/^ExecStart=/iExecStartPre=/bin/sleep 10" "$F2BUNIT"
245245
grep -q sleep "$SWPUNIT" || sed -i "/\<start)/asleep 30" "$SWPUNIT"
246246

247+
# disable ncp user login
248+
chsh -s /usr/sbin/nologin ncp
249+
247250
} # end - only live updates
248251

249252
exit 0

0 commit comments

Comments
 (0)