If you are using a headless setup for your Raspberry Pi, you can easily set up a wpa_supplicant.conf file to connect to wifi. But it is very important to mask your password for security reasons. In this post, I will show you how.

Your wpa_supplicant.conf file has network objects that look like this:

network={
    ssid="testNetwork"
    psk="testingPassword"
}

Where ssid is your network name and psk is your password. But you’ll notice that that is just a plain text password, which we all know is a no-no.

Use this command: wpa_passphrase [ssid-name] [password-name] and be sure to wrap the network and/or password in quotes if you have spaces in either.

This command will spit out a new network object that looks like this:

network={
	ssid="testNetwork"
	#psk="testingPassword"
	psk=575827beef2c7dbdcf817a9cd0e6b96fb0fd3f54e2c0fbf24a38eb04fb7e9aa3
}

Copy this and use sudo nano /etc/wpa_supplicant/wpa_supplicant.conf and add this new network object to the file, or edit the old network object with the new passphrase. Just be sure to delete the commented-out plain text password from the file before you save it.

You can use the iwgetid command to confirm which network you are connected to. And you’re good to go!

Questions? Tweet me!

Sign up for blog updates!

* indicates required