While its been proven a fair few times that with a well crafted photo you can enter most systems with facial recognition. For a personal PC there is something kinda of nice about looking at the webcam unlocking your login session, lock screen or providing sudo access.
Using howdy this is done using very little user tweaking of things like pam.
This will work on most modern linux systems and the guys github page points you in the right direction for most distros
For this guide however I will focus on Ubuntu 20.04.1 Desktop 64bit.
Some things to be aware of..
- All the data for this photos etc is stored locally
- Howdy is built using OpenCV and Python
- The installation is going to take about 600Mb of space on your disk
- Facial recognition isn't 100% secure and should never be your primary method of access on a production system.
Howdy is installed via an Ubuntu PPA
sudo add-apt-repository ppa:boltgolt/howdy
sudo apt update
sudo apt install howdy
The installation isn't your normal sit back and you're done install, its interactive and may look like its erroring out some times.
There is a question about how you wish Howdy to perform with the answers being
- Fast - The facial matches are more "fuzzy" however is quicker
- Balanced - Still quite quick, however if you're further away may not log you in
- Secure - As the name suggests it is secure however will be slower
I chose Balanced and have had good results so far
You may also get what look like errors as what I assume is a make file or a python installer working that look like this
This seems to be ok
The whole installation takes about 5 minutes on my Dell XPS 13 (2019)
There may be questions about your webcam, and I just said yes to the defaults as we can edit that once Howdy is installed.
Once Complete its time to setup that webcam
Setup your webcam
Howdy uses some IR detection and needs both Video Capture AND Metadata capture on the webcam
We can find out more about the webcam by installing v4l-utils
sudo apt install v4l-utils
Once installed you will want to list the video devices on the system
This should return something like this
Integrated_Webcam_HD: Integrate (usb-0000:00:14.0-5): /dev/video0 /dev/video1
Which is interesting because I only have one webcam on the device
Remember we needed to find out if the webcam did both video and metadata caputure, we can use the following command
v4l2-ctl --device=/dev/video0 --all | grep Capture
This will return something like this
Video Capture Metadata Capture Video Capture Format Video Capture: Crop Capability Video Capture: Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags: Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags: Streaming Parameters Video Capture:
Whoch would indicate the camera supports BOTH capture modes, specifically the first two lines
Video Capture Metadata Capture Video Capture
For reference running the command without the grep returns a lot of data about your video camera
v4l2-ctl --device=/dev/video0 --all
On 99.9% of systems /dev/video0 should be the right webcam
Update the Howdy Config
Once you know the location of your video device, the Howdy config needs to be edited
There are two ways of doing this
sudo howdy config
sudo nano /lib/security/howdy/config.ini
The former basically runs the latter, both will open the config file in nano
Run a search for device_path and edit it to look like this
# The path of the device to capture frames from # Should be set automatically by an installer if your distro has one device_path = /dev/video0
Save and exit the file
Other Config Options
Well I say save and exit, however there are other options in this config file some which may help debugging if you have issues later. Some examples include
# The certainty of the detected face belonging to the user of the account # On a scale from 1 to 10, values above 5 are not recommended # Lower is better certainty = 2.8
# Disable Howdy in remote shells ignore_ssh = true
# The number of seconds to search before timing out timeout = 4
Its worth having a look at the other options.
Provide your Face Images
The software is installed, the webcam is setup next it is time to add your face
sudo howdy add
You'll run the add command, look at the webcam, if the webcam light goes on for a few seconds then off, you have sucessfully added a new Face profile, you can add as many of these as you want.
NOTICE: Each additional model slows down the face recognition engine slightly Press Ctrl+C to cancel Adding face model for the user david Enter a label for this new model [Model #1] (max 24 characters)
Add a name, and pose looking at the camera
Please look straight into the camera Scan complete Added a new model to david
Use the following command to list the face models you have
sudo howdy list
This should return someting like this
Known face models for david: ID Date Label 0 2020-09-01 17:24:05 face1 1 2020-09-01 17:24:22 face2 2 2020-09-01 17:24:34 face3 3 2020-09-01 17:26:12 face side 4 2020-09-01 19:51:50 slightly darker room
Should you want to remove one run the command
sudo howdy remove <ID> Example: sudo howdy remove 3
This would remove "face side"
To clear all the ID's run
sudo howdy clear
Take 2 or 3 Face photos closer, further away, bright light, darker room etc
Its time to test this out. The first test is checking Sudo access works
Open a new Terminal/Terminal Tab
sudo howdy list
Watch the webcam light, it should go on, for about 4 seconds and then display
Identified face as david Known face models for david: ID Date Label 0 2020-09-01 17:24:05 face1 1 2020-09-01 17:24:22 face2 2 2020-09-01 17:24:34 face3 3 2020-09-01 17:26:12 face side 4 2020-09-01 19:51:50 slightly darker room
The next test is the Lock screen
Click on Lock to lock the screen
Then press space to unlock
Again the webcam should go on for 4 seconds and unlock the screen
Finally test the Login screen, reboot and try and login
After the webcam light goes on, 4 seconds and you should login
You're done. Facial recognition is enabled on your Ubuntu install
What does the installer change?
The Pam Module /etc/pam.d/pam-auth has a line added
auth [success=2 default=ignore] pam_python.so /lib/security/howdy/pam.py
Which has the PAM module call the python script each time authentication needs to take place.
Other Howdy Commands
The installer adds a
howdy command to manage face models for the current user. Use
howdy --help or
man howdy to list the available options.
howdy [-U user] [-y] command [argument]
- add - Add a new face model for an user
- clear - Remove all face models for an user
- config - Open the config file in your default editor
- disable - Disable or enable howdy
- list - List all saved face models for an user
- remove - Remove a specific model for an user
- snapshot - Take a snapshot of your camera input
- test - Test the camera and recognition methods
- version - Print the current version number
While I would never recommend this on a production system, I do advocate the usage from a pure laziness factor. Because of this I'm now going to figure out how to setup proximity locking on Ubuntu.
On the XPS13 i7 the results are quick and so far in a home situation this has worked really well.