Skip to content
rylosPublic

About

Face authentication for Linux in pure Rust: a Windows Hello-style replacement for Howdy that works on every distro

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

ryface

Windows Hello–style face login for Linux, in pure Rust.

A fast, spoof-resistant replacement for Howdy: sudo, polkit, run0, lock screens, greeters and the console unlock with your face.
Deep neural networks, CPU only: no GPU, no CUDA, no drivers. Unlocks in under a second.
No Python, no dlib, no OpenCV. One daemon, one PAM module.

Latest release AUR CI License: MIT OR Apache-2.0 Rust CPU only, no GPU Linux Status: beta

Install · Why · Neural recognition · From Howdy · How it works · Docs

Look at the IR camera, and sudo, the polkit dialog or the lock screen opens in well under a second. Look away, hold up a photo or a phone, and nothing happens: your password still works as always.

Note

Beta. ryface runs daily on the maintainer's machines, where it has replaced Howdy for sudo, polkit, the lock screen and the display manager. Expect rough edges until 1.0; your password always keeps working.

Fast, on the CPU alone

No GPU, no CUDA, no vendor drivers, no ML runtime to install: the neural networks run on the processor, through a pure-Rust inference engine. It works the same on a laptop with integrated graphics, a desktop with any graphics card, or a machine with none.

Unlock 0.26–1.0 s from camera on to decision, liveness check included
Face detection 17 ms per frame (YuNet), CPU
Face embedding 41 ms per frame (SFace), CPU
Camera start first frame in ~320 ms, then a steady 30 fps
GPU not used, not needed
Idle cost zero: the daemon is started on demand by D-Bus and exits after 30 s idle (daemon.idle_timeout)
Dependencies at run time libc, libpam, D-Bus, polkit. Nothing else

Where the time goes in a typical unlock: the camera needs about a third of a second to wake up and deliver its first frame; then each frame is detected, aligned and embedded in under 60 ms, and a decision needs a few matching frames, each checked for IR liveness with the emitter on and off. Most of the wait is the camera, not the computation.

Measured on an AMD Ryzen 7 1800X (2017) with a 480×360 IR camera at 30 fps, release build. While running, the daemon uses about 85 MB of its own memory, mostly the two neural networks.

Neural face recognition

ryface recognises faces the way modern phones and Windows Hello do: with deep convolutional neural networks trained for faces, not with hand-written rules. Every camera frame goes through four steps, all on the CPU, inside the daemon:

  1. Find the face. YuNet, a tiny neural detector built for millisecond speed, finds every face in the frame and five landmarks on each: eyes, nose tip, mouth corners. It needs no frontal pose or even lighting, and it ignores faces in the background.
  2. Straighten it. The five landmarks are mapped onto a reference face with a similarity transform (rotation, scale, shift), so a tilted or off-centre head becomes the same upright 112×112 crop every time.
  3. Turn it into numbers. SFace, a MobileFaceNet network trained with the Sigmoid-Constrained Hypersphere Loss, turns the crop into a 128-number face embedding: a point on a sphere where pictures of the same person land close together and different people land far apart, whatever the expression, glasses or stubble. Its reference accuracy in the OpenCV Zoo evaluation is 99.40 %.
  4. Compare and decide. The embedding is compared with your enrolled ones by cosine similarity. A login needs several matching frames in a row, each also passing the IR liveness check, so one lucky frame is never enough.

What this brings in practice:

  • Robust. Glasses, a beard, a new haircut, a different angle or dim light do not stop it: the network learned what stays the same in a face. The pose-guided enrolment adds views from slightly left, right, up and down.
  • Works on IR. Trained on ordinary photos, the embeddings still separate people well in infrared. Measured on the maintainer's IR camera: 0.88–0.95 similarity for the enrolled user, against a default threshold of 0.50.
  • Fast without a GPU. 17 ms to detect, 41 ms to embed, on a 2017 desktop CPU. No CUDA, no driver, no GPU memory.
  • Built in, verified, private. Both networks (about 39 MB) are compiled into the daemon, checked by SHA-256 at build time and run by tract, a pure-Rust inference engine. Nothing is downloaded at install or run time, and no picture or embedding ever leaves the machine.
  • Permissive licenses. YuNet is MIT and SFace is Apache-2.0, so ryface stays usable by anyone, companies included. Models with non-commercial licenses (InsightFace and others) were left out on purpose.

Why ryface

  • Neural recognition. Deep networks find, align and identify your face, robust to glasses, beard, angle and dim light, in tens of milliseconds on the CPU (details).
  • Nothing to break. No Python, dlib, OpenCV, CUDA or ML system libraries. The neural networks are embedded in the daemon and pinned by SHA-256, and inference is pure Rust (tract). A distribution update can no longer break your login, which is what happens to Howdy when python-dlib or its dependencies change.
  • A photo never unlocks. Like Windows Hello, ryface needs an IR camera and checks that the face is real. It compares frames with the IR emitter on and off: a real face shows 3-D relief (the nose sends back far more IR than the cheeks), a print is flat, and screens give off no IR at all. Liveness cannot be switched off for logins.
  • Every login point. sudo, run0, polkit dialogs (including rbw-enhanced and other password managers that unlock through polkit), lock screens, display managers and the console. The camera lives in the daemon, so it works even inside polkit's sandboxed helper: no PrivateDevices=no drop-in, no system hacks.
  • Safe with PAM. Installing never edits PAM. ryface pam enable adds one marked line, keeps a backup, uses pam-auth-update on Debian and Ubuntu, and pam disable --all (or uninstalling) removes it. A failed face check never counts against pam_faillock, and SSH sessions are refused by design.
  • Sets itself up. The first enrolment measures your camera, distance and light and sets the quality limits for you. You turn your head slightly during enrolment, so the model recognises you from more than one angle.
  • Locked down. The daemon runs as its own system user, sandboxes itself with Landlock and seccomp (with or without systemd), and stores face models encrypted (ChaCha20-Poly1305), one file per user. Pictures never leave the machine.
  • Any distro. Only standard interfaces: V4L2, PAM, D-Bus, polkit, logind or elogind. CI builds, installs and toggles PAM on Arch, Debian, Ubuntu, Fedora, openSUSE, Alpine (musl) and Void.
  • A real CLI to build on. Every command takes --json and returns stable exit codes, and the D-Bus API is documented. Anyone can build a GUI on top.

Coming from Howdy

Howdy ryface
Language and stack Python, dlib, OpenCV, optional CUDA Rust, models embedded, CPU only
Face detection dlib HOG by default (hand-made features), CNN only with CUDA to be fast YuNet neural network, 17 ms on the CPU
Face recognition dlib ResNet, 128-d (2017) SFace MobileFaceNet, 128-d, landmark-aligned
Breaks after system updates often (python-dlib, OpenCV, Python versions) no system ML libraries to break
Photo or phone screen depends on setup refused: IR liveness always on
polkit sandbox (polkit-agent-helper@) needs a systemd drop-in works unchanged
PAM changes by hand ryface pam enable / disable, with backup
Camera choice set by hand IR camera found automatically
Thresholds by hand measured at first enrolment, can be changed
Machine-readable output no --json and stable exit codes

To switch, install ryface, enrol, run sudo ryface pam enable … (the ryface line goes above Howdy's), and check with ryface doctor. It points out the Howdy lines and the polkit drop-in you can remove once you are happy. Howdy's dlib models cannot be imported: enrolling again takes about 20 seconds.

Install

Arch Linux, from the AUR: ryface (release) or ryface-git (development version):

yay -S ryface            # or paru -S ryface, or git clone + makepkg -si

Debian 13 and Ubuntu, amd64: each release has the .deb, built by GitHub Actions, with its SHA256SUMS:

curl -fLO https://github.com/rylos/ryface/releases/latest/download/ryface_<version>-1_amd64.deb
sudo apt install ./ryface_<version>-1_amd64.deb

Any other distribution, from source (Rust 1.91 or newer):

cargo build --release
sudo cargo xtask install --prefix /usr     # or --destdir for packaging

No package or install step ever edits PAM: that happens only when you run ryface pam enable, and removing the package takes ryface out of PAM again.

Set up

ryface devices                    # the cameras found; the IR one is used
ryface enroll                     # sit as usual, look at the camera, then turn slightly
ryface test                       # live view: face box, similarity, liveness, MATCH
sudo ryface pam enable sudo polkit-1           # sudo, run0, authentication dialogs
sudo ryface pam enable system-local-login      # lock screen and console login (Arch layout)
ryface doctor                     # checks everything, points out Howdy leftovers

ryface setup walks through the same steps interactively. Lock screens that only call PAM once you press Enter (Noctalia, swaylock) need an empty Enter to start the camera; in Noctalia set allow_empty_password = true.

Which camera

With device = "auto" (the default) the daemon picks the first physical camera that only offers greyscale formats. That is how IR cameras show up: colour webcams offer YUYV or MJPG, and virtual cameras (v4l2loopback) are skipped. ryface devices shows what was found and which one is used. To pin a camera:

sudo ryface config set camera.device by-path:pci-0000:02:00.0-usb-0:13.2:1.2-video-index0

Use a by-path: name when two identical cameras share the same serial number. by-id: names and /dev/videoN paths work too.

No IR camera

Without an IR camera ryface does not unlock anything: ryface status and ryface doctor say so. The fallback_rgb = true setting lets a colour webcam be used for ryface test and ryface preview, but the liveness check needs the IR emitter, so logins with a colour webcam always fail. A photo must never be enough.

More faces, more users

  • Each user enrols themselves with ryface enroll, confirming with their own password (polkit). Root can enrol anyone: sudo ryface enroll -u alice.
  • Each user is matched only against their own models, stored encrypted in their own file. Your face does not unlock anyone else's account.
  • Several models per user, for example with and without glasses: ryface enroll --label glasses. ryface list shows them, ryface remove <id> deletes one, ryface clear deletes them all.

Password managers

Password managers that unlock through polkit open by face once polkit-1 is enabled. rbw-enhanced, a Bitwarden client for the terminal, unlocks the vault and opens its TUI this way:

sudo ryface pam enable polkit-1
rbw config set system_auth true   # unlock the vault through polkit
rbw config set tui_auth true      # also ask for the face to open rbw tui

No polkit sandbox drop-in is needed, unlike with Howdy.

Commands

Command Purpose
ryface setup guided first run
ryface enroll [--label L] [-u USER] [--calibrate] add a face model (pose-guided, liveness checked)
ryface test [--once] [--render kitty|sixel|blocks] live camera with match, liveness and quality
ryface list / remove <id> / clear manage face models
ryface devices / preview cameras, and a raw camera view
ryface status / doctor daemon state / installation check
ryface config show|get|set|edit|validate configuration
ryface pam status|enable|disable PAM integration

--json everywhere (NDJSON for streams). Exit codes: 0 ok, 1 no match, 2 usage, 3 spoof, 4 unavailable, 5 daemon unreachable, 6 permission denied, 7 locked out, 10 internal, 11 not implemented.

Configuration

Most people never touch it. Layers, each overriding the previous one: built-in defaults, /usr/share/ryface/config.toml (commented reference), the measurements of the first enrolment (/var/lib/ryface/calibration.toml), /etc/ryface/config.toml and /etc/ryface/config.d/*.toml. ryface config set writes a validated drop-in. The daemon picks up changes within a second, and an invalid file is refused while the previous configuration stays in use.

Advanced users can tune auth.threshold (similarity), [quality] (distance, light, sharpness, head angle) and [liveness]. Similarity and liveness can be made stricter but never weaker than the safe minimum: such a configuration is refused. ryface enroll --calibrate measures again, for example after moving the camera. See data/config.toml.

How it works

 sudo / polkit / greeter / lock screen
        │  PAM
        ▼
 pam_ryface.so ──D-Bus (system bus)──▶ ryfaced  (user "ryface", Landlock + seccomp)
   thin client                           │ IR camera (V4L2, emitter on/off frames)
   trusts only the real daemon           │ YuNet: face + landmarks
                                         │ SFace: 128-d face embedding
                                         │ liveness: IR relief, lit vs unlit
                                         ▼
                              encrypted models in /var/lib/ryface

The same split as fprintd: the PAM module never touches the camera or the models, it asks the daemon and gets back match, no match, spoof or unavailable. Unavailable (no camera, lid closed, remote session, lockout) falls through to the password at once.

Documentation

Document Content
00-context What breaks with Howdy today, goals, non-goals, target hardware
01-research Howdy 3.0, Windows Hello, fprintd, polkit, Rust ecosystem, models and licenses
02-architecture Components, pipeline, D-Bus API, storage, PAM module, CLI contract
03-integrations Every login point and how ryface plugs into it
04-security Threat model, liveness, lockout, privacy
05-decisions Decision register
06-roadmap Milestones and acceptance criteria
07-portability Standards and portability
progress Implementation log and measurements
CHANGELOG What changed in each release

License

MIT OR Apache-2.0, at your option. Embedded models: YuNet (MIT) and SFace (Apache-2.0), from the OpenCV Zoo; see models/MODELS.md.

ryface is an independent project, not affiliated with Howdy, Microsoft or Windows Hello. Windows Hello is a trademark of Microsoft Corporation, named here only for comparison.

Made in Italy 🇮🇹

About

Face authentication for Linux in pure Rust: a Windows Hello-style replacement for Howdy that works on every distro

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages