I use a .netrc file for authentication args for git. I have test automation that configures an Android device before executing tests, and I need the device joined to a corp wifi network. I've scripted this by adding the following parameters to the wpa_supplicant.conf and pushing it back:
WIRELESS_CTRL_INTERFACE=wlan0
WIRELESS_SSID=ST-DEV
WIRELESS_KEY_MGMT="WPA-EAP IEEE8021X"
WIRELESS_EAP=PEAP
WIRELESS_USER=[me]
WIRELESS_PASSWORD=[my password]
I'd like to use .netrc for this, if possible, so the config script can be checked into source and shared with the team and they can use their credentials, and we'll only need to update our .netrc when our passwords expire.
But it looks like .netrc matches remote machine names. Is there a way to get .netrc to see my SSID ST-DEV
as a machine name token and populate the two credential variables when the script is executed with what I safely store in .netrc so that the updated wpa_supplicant.conf
pushed back to the Android device remains current?
Figured it out: use
awk
to parse.netrc
, assign the credentials to the variables, write them towpa_supplicant.conf
and push it to the device. Works!You'll need
awk
. You'll also want your script torm
the local copy ofwpa_supplicant.conf
once complete because your password is still in plaintext there (yep, Android stores your wifi passwords in plaintext).