Sometimes you just want the security of a long complicated WiFi password without the hassle of having to share it with your guests every time they come over to your house. Well that’s where a conveniently placed QR code comes in!
By embedding your WiFi details in a QR code using a standard that both Android and iOS can understand you can easily give out your WiFi details to guests when they arrive just by having them scan a code somewhere in your house.
The QR code standard that mobile devices understand comes in the following format:
WIFI:S:{SSID name of your network};T:{security type - WPA or WEP};P:{the network password};;
Special characters should be escaped using a “\” character. So for example if your WiFi name was “Tux” and your password was “thelinuxexperiment.com” using WPA encryption you would encode:
WIFI:S:Tux;T:WPA;P:thelinuxexperiment.com;;
OK so now we know the standard but how do we create the QR codes? Well there are plenty of good websites around that will do it for you, but if you’re a little bit weary of putting your WiFi security details into a website you can instead choose to do it offline with a program that does it all on your local machine. For this example I’m going to use qrencode but there are others.
sudo apt install qrencode
Qrencode allows you to create QR code images with a given text. We’ll use the info above as an example:
qrencode -o wifi.png 'WIFI:S:Tux;T:WPA;P:thelinuxexperiment.com;;'
If the resulting QR code is too small you can increase it by also passing the -s flag. The default value is 3 so for example if you passed -s 10 it would make the image substantially larger.
Once you have your image you can simply print it off and let your guests scan it when they want access!
Can you get this to work the other way around somehow? So scanning a QR code displayed on a phone to connect a Linux machine to the wifi?
Re: Dave
I haven’t tested it, but the README for https://github.com/kokoye2007/wifi-qr says that it should be able to do what you want if invoked as “sudo wifi-qr s” (automatic) or “sudo wifi-qr q” (show prompt).
Great tutorial, thank you for sharing this. I love how simple it is do stuff like this on a Unix system!
Thank you for this!
I just used qrencode to create a QR code for my guest WiFi network.