setup-hub.sh: remove unnecessary sudo/wheel group membership for hub user

This commit is contained in:
Justin Oros
2026-04-19 10:36:32 -07:00
parent b735c58446
commit 2fe94dfe9d

View File

@@ -118,21 +118,6 @@ else
groupadd -g 1000 "$HUB_USER" 2>/dev/null || true
useradd -m -u 1000 -g 1000 -s /bin/bash "$HUB_USER"
ADDED_TO_GROUP=false
if getent group sudo >/dev/null 2>&1; then
if usermod -aG sudo "$HUB_USER" 2>/dev/null; then
ADDED_TO_GROUP=true
fi
fi
if [ "$ADDED_TO_GROUP" = false ] && getent group wheel >/dev/null 2>&1; then
if usermod -aG wheel "$HUB_USER" 2>/dev/null; then
ADDED_TO_GROUP=true
fi
fi
if [ "$ADDED_TO_GROUP" = false ]; then
warn "Neither sudo nor wheel group found — $HUB_USER user has no sudo access."
fi
info "$HUB_USER user created."
echo ""
warn "Set a password for the $HUB_USER user:"
@@ -142,7 +127,7 @@ fi
ARMBIAN_HOME="/home/$HUB_USER"
SSH_DIR="$ARMBIAN_HOME/.ssh"
mkdir -p "$SSH_DIR"
touch "$SSH_DIR/authorized_keys"
[ -f "$SSH_DIR/authorized_keys" ] || touch "$SSH_DIR/authorized_keys"
chown -R "$HUB_USER":"$HUB_USER" "$SSH_DIR"
chmod 700 "$SSH_DIR"
chmod 600 "$SSH_DIR/authorized_keys"
@@ -183,12 +168,12 @@ if [[ "${DISABLE_PASS,,}" == "y" ]]; then
warn "No keys found in $SSH_DIR/authorized_keys — skipping password auth disable to avoid lockout."
else
if grep -q "^PasswordAuthentication" "$SSHD_CONF"; then
sed -i "s/^PasswordAuthentication.*/PasswordAuthentication no/" "$SSHD_CONF"
sed -i "s|^PasswordAuthentication.*|PasswordAuthentication no|" "$SSHD_CONF"
else
echo "PasswordAuthentication no" >> "$SSHD_CONF"
fi
if grep -q "^PubkeyAuthentication" "$SSHD_CONF"; then
sed -i "s/^PubkeyAuthentication.*/PubkeyAuthentication yes/" "$SSHD_CONF"
sed -i "s|^PubkeyAuthentication.*|PubkeyAuthentication yes|" "$SSHD_CONF"
else
echo "PubkeyAuthentication yes" >> "$SSHD_CONF"
fi