Skip to content

Instantly share code, notes, and snippets.

Last active Apr 9, 2021
What would you like to do?
# Author URI:
# Use /dev/random to generate a strong random passphrase.
# If pronounceable, but less secure, passphrases are desired, install gpw (sudo apt install gpw)
# and replace it with: gpw 1 24
readonly HOSTAPD="/etc/hostapd/hostapd.conf"
readonly PASSPHRASE=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32 ; echo '')
echo "Your new passphrase is: ${PASSPHRASE}"
# Update hostapd.conf wpa_passphrase
sudo sed -i "s/\(wpa_passphrase=\).*/\1${PASSPHRASE}/g" "$HOSTAPD" || { echo "Unable to modify hostapd.conf" && exit; }
# Restart RaspAP for change to take effect
sudo systemctl restart raspapd.service || { echo "Unable to restart raspapd.service" && exit; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment