Updated to create a generated password
This commit is contained in:
28
setup.sh
28
setup.sh
@@ -41,7 +41,7 @@ systemctl restart ssh || service ssh restart
|
||||
|
||||
# === INSTALL BASIC UTILITIES ===
|
||||
echo "Installing base packages..."
|
||||
apt install -y curl wget vim git ufw
|
||||
apt install -y curl wget vim git ufw wamerican
|
||||
|
||||
# === FIREWALL CONFIGURATION ===
|
||||
echo "Configuring firewall..."
|
||||
@@ -57,4 +57,30 @@ systemctl restart ssh || service ssh restart
|
||||
# === ENSURE beer CAN USE SUDO ===
|
||||
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'."
|
||||
|
||||
Reference in New Issue
Block a user