Although there are easy ways connect to wifi using "sudo raspi-config" , I have decided to stick with CLI so that we will know what is happening behind the fancy screens ;) Come on, you dont get high when it is easy :).
On a serious note, it doesnt encypt the PSK - that is the actual reason..
Following are the steps I followed :
Step 1 - Scan the Network by issuing the following command
sudo iwlist wlan0 scan
Step 2 - Generate an encrypted PSK (pre-encrypted 32 byte hexadecimal number) and then you will be asked for the password of the WiFi network
Then you will be asked for the password of the WiFi network (in this case testingPassword). The output is as follows:
You can ideally copy paste this to /etc/wpa_supplicant/wpa_supplicant.conf, but one should be nuts id you don't delete the clear text password (commented in above example)
Also, you can do this in a diff way when you are more lazy (again delete the clear text as needed, dont be that ;))
wpa_passphrase "testing" >> /etc/wpa_supplicant/wpa_supplicant.conf
Now save the file by pressing Ctrl+X, then Y, then finally press Enter.
Reconfigure the interface by issuing the following command
wpa_cli -i wlan0 reconfigure
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.
On the Raspberry Pi 3 Model B+, you will also need to set the country code, so that the 5G networking can choose the correct frequency bands. You can either use the raspi-config application and select the localisation option, or edit the wpa_supplicant.conf file and add the following. (Note you need to replace 'GB' with the ISO code of your country. See Wikipedia for a list of country codes.)
Its time for QA -
What about unsecured networks ?
If the network you are connecting to does not use a password, the wpa_supplicant entry for the network will need to include the correct key_mgmt entry. e.g.
What about hidden networks ?
If you are using a hidden network, an extra option in the wpa_supplicant file, scan_ssid, may help connection.
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 your password and ESSID are correct.
What about adding multiple wireless network configurations?
On recent versions of Raspbian, it is possible to set up multiple configurations for wireless networking. For example, you could set up one for home and one for school.
If you have two networks in range, you can add the priority option to choose between them. The network in range, with the highest priority, will be the one that is connected.
Finally, what about me ?
Well, thats THE same... Still counting on you, will try my best before I call it..... On a serious note, that was a silly question, seldom cares.. Thanks for asking - see you next time ?