What's new

Set WPA/2 Pass Phrase From Command Line - How To.

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

SteveM

Occasional Visitor
Hi.

I've got an Asus ax58U running Merlin as my main router and an N56U as an AP running Padavan.

I'm doing a bit of hacking around guest networks - Using Alexa to enable the Guest network and the ax58

When it does enable the network I have a script (/jffs/scripts/service-event-end) which tests to see if the Guest network is up and if so it uses SSH to execute a command on the on the N56 to bring up the guest network there (and to do the reverse when the Guest on the ax58 is disabled.

The problem is on the ax58 whereby the SSID is generated by the router and a changing password is used. I want the details to match what's on the N56

So the following works on the ax58:
Bash:
wl -a wl1.3 ssid="MyGuestSSID"
wl -a wl0.3 ssid="MyGuestSSID"

However I can't seem to change the pass phrase. I thought this would do the trick:
Bash:
wl -a wl1.3 set_pmk MyPassPhrase
wl -a wl0.3 set_pmk MyPassPhrase
I get a wl: Unsupported response.

Does anyone know how to set the pass phrase via script/command-line?

Conversely is there any way to force the router to use a pre-defined passphrase when Alexa enables the guest.
 
Hi.

I've got an Asus ax58U running Merlin as my main router and an N56U as an AP running Padavan.

I'm doing a bit of hacking around guest networks - Using Alexa to enable the Guest network and the ax58

When it does enable the network I have a script (/jffs/scripts/service-event-end) which tests to see if the Guest network is up and if so it uses SSH to execute a command on the on the N56 to bring up the guest network there (and to do the reverse when the Guest on the ax58 is disabled.

The problem is on the ax58 whereby the SSID is generated by the router and a changing password is used. I want the details to match what's on the N56

So the following works on the ax58:
Bash:
wl -a wl1.3 ssid="MyGuestSSID"
wl -a wl0.3 ssid="MyGuestSSID"

However I can't seem to change the pass phrase. I thought this would do the trick:
Bash:
wl -a wl1.3 set_pmk MyPassPhrase
wl -a wl0.3 set_pmk MyPassPhrase
I get a wl: Unsupported response.

Does anyone know how to set the pass phrase via script/command-line?

Conversely is there any way to force the router to use a pre-defined passphrase when Alexa enables the guest.
borrowing from my YazFi code, you can set it in nvram
Code:
nvram set "${1}_wpa_psk"="$2"
nvram set "${1}_auth_mode_x"="psk2"
nvram set "${1}_akm"="psk2"
nvram commit
service restart_wirelesss
where $1 in this case is the interface e.g. wl0.1 and $2 is the passphrase to use

I generate random passphrases using:
Code:
Generate_Random_String(){
    PASSLENGTH=16   
    < /dev/urandom tr -cd 'A-Za-z0-9' | head -c "$PASSLENGTH"
}
newpassphrase="$(Generate_Random_String)"
newpassphraseclean="$(echo "$newpassphrase" | sed 's/[^a-zA-Z0-9]//g')"

which probably has room for improvement (looking at it again I'm not sure why I sed after specifying a character set!) but might be a good place for you to start
 
borrowing from my YazFi code, you can set it in nvram
Code:
nvram set "${1}_wpa_psk"="$2"
nvram set "${1}_auth_mode_x"="psk2"
nvram set "${1}_akm"="psk2"
nvram commit
service restart_wirelesss
where $1 in this case is the interface e.g. wl0.1 and $2 is the passphrase to use

I generate random passphrases using:
Code:
Generate_Random_String(){
    PASSLENGTH=16  
    < /dev/urandom tr -cd 'A-Za-z0-9' | head -c "$PASSLENGTH"
}
newpassphrase="$(Generate_Random_String)"
newpassphraseclean="$(echo "$newpassphrase" | sed 's/[^a-zA-Z0-9]//g')"

which probably has room for improvement (looking at it again I'm not sure why I sed after specifying a character set!) but might be a good place for you to start
Brilliant!

I've add the relevant changes into the services-event script, but didn't issue the service restart_wireless (otherwise and endless loop I guess)

Code:
case $1 in
start)
  case $2 in
    wireless)
      nvram set wl0.3_ssid="MyGuest"
      nvram set wl0.3_wpa_psk="MyPSK"
      nvram set wl1.3_ssid="MyGuest"
      nvram set wl1.3_wpa_psk="MyPSK"
      nvram commit
    ;;

  esac
  ;;

stop)

  ;;

restart)
  case $2 in
    wireless)
      nvram set wl0.3_ssid="MyGuest"
      nvram set wl0.3_wpa_psk="MyPSK"
      nvram set wl1.3_ssid="MyGuest"
      nvram set wl1.3_wpa_psk="MyPSK"
      nvram commit
    ;;

  esac

  ;;

esac
 
All I need to now sort out is how to report back to Alexa the corrected SSID & PSK to make this work seamless.

Any idea how Alexa integrates with the ax58 anyone
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top