Update Setup.sh
This commit is contained in:
parent
2db7a5099d
commit
8339a5e3ed
1 changed files with 11 additions and 5 deletions
|
|
@ -11,24 +11,30 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
echo "[+] Creating /root/.ssh if it doesn't exist..."
|
||||
echo "[1/5] Updating system..."
|
||||
apt update && apt upgrade -y
|
||||
|
||||
echo "[2/5] Installing sudo and curl..."
|
||||
apt install -y sudo curl
|
||||
|
||||
echo "[3/5] Creating /root/.ssh if needed..."
|
||||
mkdir -p "$SSH_DIR"
|
||||
chmod 700 "$SSH_DIR"
|
||||
|
||||
echo "[+] Adding your SSH key to /root/.ssh/authorized_keys..."
|
||||
echo "[4/5] Adding SSH key to /root/.ssh/authorized_keys..."
|
||||
touch "$AUTHORIZED_KEYS"
|
||||
grep -qxF "$SSH_KEY" "$AUTHORIZED_KEYS" || echo "$SSH_KEY" >> "$AUTHORIZED_KEYS"
|
||||
chmod 600 "$AUTHORIZED_KEYS"
|
||||
|
||||
echo "[+] Disabling password authentication for SSH..."
|
||||
echo "[5/5] Disabling SSH password authentication..."
|
||||
sed -i 's/^#\?\s*PasswordAuthentication\s\+.*/PasswordAuthentication no/' /etc/ssh/sshd_config
|
||||
sed -i 's/^#\?\s*ChallengeResponseAuthentication\s\+.*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
|
||||
|
||||
echo "[+] Restarting SSH service..."
|
||||
echo "[✓] Restarting SSH service..."
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl restart sshd
|
||||
else
|
||||
service ssh restart
|
||||
fi
|
||||
|
||||
echo "[✓] Done. SSH key added and password login disabled for root."
|
||||
echo "[✔] Setup complete. Root login via SSH key is enabled. Password login is disabled."
|
||||
Loading…
Add table
Add a link
Reference in a new issue