Skip to content

Commit abefe3e

Browse files
authored
Update wireless-cli.md (raspberrypi#652)
* Update wireless-cli.md * copy edit * Copy edit
1 parent b4cc4f6 commit abefe3e

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

configuration/wireless/wireless-cli.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,7 @@ To scan for WiFi networks, use the command `sudo iwlist wlan0 scan`. This will l
99

1010
1. 'ESSID:"testing"' is the name of the WiFi network.
1111

12-
1. 'IE: IEEE 802.11i/WPA2 Version 1' is the authentication used. In this case it's WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. For WEP hex keys, see the last example [here](http://www.freebsd.org/cgi/man.cgi?query=wpa_supplicant.conf&sektion=5&apropos=0&manpath=NetBSD+6.1.5). You'll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router. The ESSID (ssid) for the network in this case is `testing` and the password (psk) is `testingPassword`.
13-
14-
1. You can use `wpa_passphrase` to generate the PSK and enter it. With the example from above, calling the command will be `wpa_passphrase "testing"`, which will ask you to enter the passphrase and output a ready-to-use wpa-compliant network profile:
15-
16-
```
17-
network={
18-
ssid="testing"
19-
#psk="testingPassword"
20-
psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531
21-
}
22-
```
23-
24-
The tool requires a password with between 8 and 63 characters. Paste the produced profile in your configuration file. For more complex passphrases you can also extract the content of a text file and use it as input for `wpa_passphrase`, if the password is stored as plain text inside a file somewhere, by calling `wpa_passphrase "testing" < file_where_password_is_stored`. You should delete the `file_where_password_is_stored` afterwards.
25-
12+
1. 'IE: IEEE 802.11i/WPA2 Version 1' is the authentication used. In this case it's WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. For WEP hex keys, see the last example [here](http://www.freebsd.org/cgi/man.cgi?query=wpa_supplicant.conf&sektion=5&apropos=0&manpath=NetBSD+6.1.5). You'll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router. The ESSID (ssid) for the examples below is `testing` and the password (psk) is `testingPassword`.
2613

2714
## Adding the network details to the Raspberry Pi
2815

@@ -31,29 +18,30 @@ Open the `wpa-supplicant` configuration file in nano:
3118
`sudo nano /etc/wpa_supplicant/wpa_supplicant.conf`
3219

3320
Go to the bottom of the file and add the following:
34-
35-
```
36-
network={
37-
ssid="The_ESSID_from_earlier"
38-
psk="Your_wifi_password"
39-
}
40-
```
41-
Note that, although `wpa_passphrase` returns the `psk` value unquoted, the `wpa_supplicant.conf` file **requires** this value to be quoted, otherwise your Pi will not connect to your network.
42-
43-
In the case of the example network, we would enter:
44-
4521
```
4622
network={
4723
ssid="testing"
4824
psk="testingPassword"
4925
}
5026
```
27+
The password can be configured either as the ASCII representation, in quotes as per the example above, or as a pre-encrypted 32 byte hexadecimal number. You can use the `wpa_passphrase` utility to generate an encrypted PSK. This takes the SSID and the password, and generates the encrypted PSK. With the example from above, you can generate the PSK with `wpa_passphrase "testing" "testingPassword`. The output is as follows.
28+
29+
```
30+
network={
31+
ssid="testing"
32+
#psk="testingPassword"
33+
psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531
34+
}
35+
```
36+
Note that the plain text version of the code is present, but commented out. You should delete this line from the final `wpa_suplicant` file for extra security.
37+
38+
The `wpa_password` tool requires a password with between 8 and 63 characters. For more complex passphrases you can extract the content of a text file and use it as input for `wpa_passphrase`, if the password is stored as plain text inside a file somewhere, by calling `wpa_passphrase "testing" < file_where_password_is_stored`. For extra security, you should delete the `file_where_password_is_stored` afterwards, so there is no plain text copy of the original password on the system.
5139

52-
If you are using `wpa_passphrase` you can redirect its output to your configuration file by calling `wpa_passphrase "testing" "testingPassword" >> /etc/wpa_supplicant/wpa_supplicant.conf`. Note that this requires you to change to `root` (by executing `sudo su`), or you can use `wpa_passphrase "testing" "testingPassword" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null`, which will append the passphrase without having to change to `root`. Both methods provide the necessary administrative privileges to change the file. Lastly, make sure you use `>>`, or use `-a` with `tee`, (both can be used to append text to an existing file) since `>`, or omitting `-a` when using `tee`, will erase all contents and **then** append the output to the specified file. Note that the redirection to `/dev/null` at the end of the second form simply prevents `tee` from **also** outputting to the screen (standard output).
40+
If you are using the `wpa_passphrase` encrypted PSK you can either copy and paste the encrypted PSK into the `wpa_supplicant.confg` file, or redirect the tools output to your configuration file by calling `wpa_passphrase "testing" "testingPassword" >> /etc/wpa_supplicant/wpa_supplicant.conf`. Note that this requires you to change to `root` (by executing `sudo su`), or you can use `wpa_passphrase "testing" "testingPassword" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null`, which will append the passphrase without having to change to `root`. Both methods provide the necessary administrative privileges to change the file. Lastly, make sure you use `>>`, or use `-a` with `tee`, (both can be used to append text to an existing file) since `>`, or omitting `-a` when using `tee`, will erase all contents and **then** append the output to the specified file. Note that the redirection to `/dev/null` at the end of the second form simply prevents `tee` from **also** outputting to the screen (standard output).
5341

54-
Now save the file by pressing Ctrl+X, then Y, then finally press Enter.
42+
Now save the file by pressing `Ctrl+X`, then `Y`, then finally press `Enter`.
5543

56-
At this point, `wpa-supplicant` will normally notice a change has occurred within a few seconds, and it will try and connect to the network. If it does not, restart the interface with `sudo wpa_cli reconfigure`.
44+
At this point, `wpa-supplicant` will normally notice within a few seconds that a change has occurred, and it will try and connect to the network. If it does not, restart the interface with `sudo wpa_cli reconfigure`.
5745

5846
You can verify whether it has successfully connected using `ifconfig wlan0`. If the `inet addr` field has an address beside it, the Raspberry Pi has connected to the network. If not, check that your password and ESSID are correct.
5947

0 commit comments

Comments
 (0)