Skip to content

Commit

Permalink
multi-factor-authentication: Remove existing authorized ssh pubkeys i…
Browse files Browse the repository at this point in the history
…f none was given

Signed-off-by: Tobias Knöppler <[email protected]>
  • Loading branch information
theCalcaholic committed Dec 17, 2019
1 parent 8215d89 commit 834f4cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/ncp/SECURITY/multi-factor-authentication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,16 @@ configure() {
echo "Restarting ssh service..."
systemctl is-enabled ssh -q && systemctl restart ssh

# Setup SSH public key if provided
if [[ -n "$ssh_pubkey" ]]
# Setup SSH public key
if [[ -n "$SSH_PUBLIC_KEY" ]]
then
echo "Setting up SSH public key..."
echo "$ssh_pubkey" > "${SSH_USER_HOME}/.ssh/authorized_keys"
chown "${SSH_USER}:" "${SSH_USER_HOME}/.ssh/authorized_keys"
elif [[ -f "${SSH_USER_HOME}/.ssh/authorized_keys" ]]
then
echo "Removing authorized ssh public key"
rm "${SSH_USER_HOME}/.ssh/authorized_keys"
fi

setup_totp_secret "$SSH_USER" "$SSH_USER_HOME"
Expand Down

0 comments on commit 834f4cd

Please sign in to comment.