diff --git a/bootstrap.sh b/bootstrap.sh index 2f530f7..6cc3e32 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -22,7 +22,7 @@ SSH_DIR="/home/$USERNAME/.ssh" # Update package list and install necessary packages echo "[+] Updating package list and installing essential packages..." apt-get update -apt-get install -y wget +apt-get install -y wget openssh-server # Setting up SSH directory and authorized keys echo "[+] Setting up SSH directory..." @@ -32,6 +32,17 @@ chown -R "$USERNAME:$USERNAME" "$SSH_DIR" chmod 700 "$SSH_DIR" chmod 600 "$SSH_DIR/authorized_keys" +# Configure SSH server to allow public key authentication +echo "[+] Configuring SSH server..." +SSH_CONFIG="/etc/ssh/sshd_config" +sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/' "$SSH_CONFIG" +sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' "$SSH_CONFIG" +sed -i 's/^#AuthorizedKeysFile/AuthorizedKeysFile/' "$SSH_CONFIG" +sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' "$SSH_CONFIG" + +# Restart SSH service to apply changes +systemctl restart ssh + # Adding user to sudo group echo "[+] Adding user to sudo group..." apt-get install -y sudo