Skip to content

Instantly share code, notes, and snippets.

@billz
Last active April 9, 2021 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billz/2cc43e96563293d650e313e068d52dfb to your computer and use it in GitHub Desktop.
Save billz/2cc43e96563293d650e313e068d52dfb to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author URI: https://github.com/billz/
# 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