Skip to content

Commit 419ccd6

Browse files
committed
multi-factor-authentication: Remove existing authorized ssh pubkeys if none was given
Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
1 parent 9d6342e commit 419ccd6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

bin/ncp/SECURITY/multi-factor-authentication.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,16 @@ configure() {
260260
echo "Restarting ssh service..."
261261
systemctl is-enabled ssh -q && systemctl restart ssh
262262

263-
# Setup SSH public key if provided
264-
if [[ -n "$ssh_pubkey" ]]
263+
# Setup SSH public key
264+
if [[ -n "$SSH_PUBLIC_KEY" ]]
265265
then
266266
echo "Setting up SSH public key..."
267267
echo "$ssh_pubkey" > "${SSH_USER_HOME}/.ssh/authorized_keys"
268268
chown "${SSH_USER}:" "${SSH_USER_HOME}/.ssh/authorized_keys"
269+
elif [[ -f "${SSH_USER_HOME}/.ssh/authorized_keys" ]]
270+
then
271+
echo "Removing authorized ssh public key"
272+
rm "${SSH_USER_HOME}/.ssh/authorized_keys"
269273
fi
270274

271275
setup_totp_secret "$SSH_USER" "$SSH_USER_HOME"

0 commit comments

Comments
 (0)