Updated to create a generated password

This commit is contained in:
2025-08-05 05:05:31 +00:00
parent 06e1350747
commit 9fb8c8b153

View File

@@ -41,7 +41,7 @@ systemctl restart ssh || service ssh restart
# === INSTALL BASIC UTILITIES === # === INSTALL BASIC UTILITIES ===
echo "Installing base packages..." echo "Installing base packages..."
apt install -y curl wget vim git ufw apt install -y curl wget vim git ufw wamerican
# === FIREWALL CONFIGURATION === # === FIREWALL CONFIGURATION ===
echo "Configuring firewall..." echo "Configuring firewall..."
@@ -57,4 +57,30 @@ systemctl restart ssh || service ssh restart
# === ENSURE beer CAN USE SUDO === # === ENSURE beer CAN USE SUDO ===
usermod -aG sudo beer usermod -aG sudo beer
# Make sure /usr/share/dict/words exists, or replace with your own file path or word array
WORDLIST="/usr/share/dict/words"
# Pick 5 random words, capitalize first letter
PASSWORD_WORDS=$(shuf -n 5 "$WORDLIST" | sed 's/.*/\L&/' | sed 's/^./\u&/' | tr '\n' ' ')
# Generate 4 random digits
PASSWORD_NUMBERS=$(shuf -i 1000-9999 -n 1)
# Combine words and numbers
GENERATED_PASS="${PASSWORD_WORDS}${PASSWORD_NUMBERS}"
# Remove trailing spaces if any
GENERATED_PASS=$(echo "$GENERATED_PASS" | xargs)
# Set password for user beer
echo "beer:$GENERATED_PASS" | chpasswd
# Show the generated password
echo "--------------------------------------------------"
echo "Generated password for user 'beer':"
echo "$GENERATED_PASS"
echo "Please save this password securely!"
echo "--------------------------------------------------"
echo "Setup complete! You can now SSH into the container/VM as '$USERNAME'." echo "Setup complete! You can now SSH into the container/VM as '$USERNAME'."