Password Generator Script :
#!/bin/bash
length=12
# Generate a random password
password=$(openssl rand -base64 $length)
echo "Generated password: $password"
Shell script that generates random passwords using
openssl
#!/bin/bash
# Function to generate random password
generate_password() {
local length="$1"
openssl rand -base64 $((length * 3 / 4)) | head -c $length
}
# Default password length
DEFAULT_LENGTH=12
# Read password length from user input
read -p "Enter the length of the password (default is $DEFAULT_LENGTH): " length
if [ -z "$length" ]; then
length=$DEFAULT_LENGTH
fi
# Generate password
password=$(generate_password $length)
echo "Generated Password: $password"
0 Comments