Password with a single quote (wpa_passphrase)

Dan Sullivan dansullivan at
Sun Dec 3 12:07:49 PST 2017


I’m trying to write a front-end wrapper that handles a subset of wpa_supplicant configuration.  I’m attempting to encode an arbitrary ASCII PSK and am getting hung up on a password that contains a single quote. I am able to satisfy the requirement of having what I would consider a sufficiently complex SSID including pizza and unicorn emojis, single and double quotes backslashes, whitespace, and an octothorp.  For example, the SSID \#"\ ' 🍕🦄  appears in the output of wpa scan_results as:

 \\#\"\\ '\xf0\x9f\x8d\x95\xf0\x9f\xa6\x84 

This works fine against wpa_passphrase if I use $’<ssid>’ by escaping the only single quote in the SSID, i.e. 

wpa_passphrase $'\\#\"\\ \'\xf0\x9f\x8d\x95\xf0\x9f\xa6\x84’ $'<somestring>'. 

In order to get this SSID to work, I have to specify it with the ssid=P syntax in wpa_supplicant.conf, which is fine.

My issue is that I cannot seem to get a password with a single quote in it to work using $’<passphrase>’ as the second argument to wpa_passphrase.  For example, if my password is: 

aaaabbbccc #\ " $ '!.

I believe that:

wpa_passphrase $'\\#\"\\ \'\xf0\x9f\x8d\x95\xf0\x9f\xa6\x84’  $'aaaabbbccc #\ " $ \’!’ 

Should effectively escape the single quote in the password to compute the hashed PSK, however it does not work when attempting to connect.

Similarly, if I remove the single quote from the passphrase on the router itself, and compute the key using 

wpa_passphrase $'\\#\"\\ \'\xf0\x9f\x8d\x95\xf0\x9f\xa6\x84’  $'aaaabbbccc #\ " $ !’

It works fine.  I know the router supports a single quote in the passphrase as I can connect to it from a another device when the single quote configured.

I have tried using both stdin and the second argument to provide the password to wpa_supplicant and both fail.  I am wondering if this may be a bug in wpa_passphrase.

I am using bash 4.4.12(1)-release and wpa_supplicant v2.4.  Any insight on resolving this issue would be greatly appreciated.


Dan Sullivan

More information about the Hostap mailing list