<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: shashank</title>
    <description>The latest articles on DEV Community by shashank (@shekh2810).</description>
    <link>https://dev.to/shekh2810</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3852981%2F28145171-c6f8-4dd3-bb35-07d4a3358f3e.jpeg</url>
      <title>DEV Community: shashank</title>
      <link>https://dev.to/shekh2810</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shekh2810"/>
    <language>en</language>
    <item>
      <title>Building a Face Authentication System for Linux (Using PAM, systemd, and ONNX)</title>
      <dc:creator>shashank</dc:creator>
      <pubDate>Tue, 31 Mar 2026 07:38:55 +0000</pubDate>
      <link>https://dev.to/shekh2810/building-a-face-authentication-system-for-linux-using-pam-systemd-and-onnx-1k7h</link>
      <guid>https://dev.to/shekh2810/building-a-face-authentication-system-for-linux-using-pam-systemd-and-onnx-1k7h</guid>
      <description>&lt;p&gt;Linux still lacks a reliable, native biometric authentication system.&lt;/p&gt;

&lt;p&gt;While platforms like Windows and macOS have tightly integrated face authentication, Linux users typically rely on passwords — or experimental tools that often break under real-world conditions.&lt;/p&gt;

&lt;p&gt;I wanted something:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fully offline&lt;/li&gt;
&lt;li&gt;predictable under PAM&lt;/li&gt;
&lt;li&gt;extensible and debuggable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I built &lt;strong&gt;AstraLock&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/shekh-2810" rel="noopener noreferrer"&gt;
        shekh-2810
      &lt;/a&gt; / &lt;a href="https://github.com/shekh-2810/AstraLock" rel="noopener noreferrer"&gt;
        AstraLock
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      AstraLock is a lightweight face-authentication system designed for Linux. It replaces legacy camera pipelines with modern deep-learning models, optimized preprocessing, and a clean, modular architecture. The goal is simple: reliable face-based login on Linux without the sluggishness, low-light failures, or angle sensitivity seen in older tools.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;AstraLock&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;AstraLock&lt;/strong&gt; is a &lt;strong&gt;Linux biometric authentication system&lt;/strong&gt; that enables &lt;strong&gt;face-based login&lt;/strong&gt; through &lt;strong&gt;PAM&lt;/strong&gt; and &lt;strong&gt;systemd&lt;/strong&gt;, designed to be &lt;strong&gt;offline, auditable, and hackable&lt;/strong&gt;, offering a native Linux alternative to projects like &lt;em&gt;Howdy&lt;/em&gt; and closed platforms such as &lt;em&gt;Windows Hello&lt;/em&gt; without cloud dependencies.&lt;/p&gt;
&lt;p&gt;It runs a local daemon that performs facial verification and integrates directly with system authentication flows such as &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;login&lt;/code&gt;, &lt;code&gt;display managers&lt;/code&gt;, and &lt;code&gt;polkit&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt; &lt;a rel="noopener noreferrer" href="https://github.com/shekh-2810/AstraLock/assets/banner.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fshekh-2810%2FAstraLock%2Fassets%2Fbanner.png" alt="AstraLock banner"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;What AstraLock Is&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A system daemon that performs face verification&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A PAM module (pam_facelock.so) for system authentication&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A CLI tool for enrollment, verification, and testing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A local-only LBPH model (no cloud, no network)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;No external services.&lt;/em&gt;
&lt;em&gt;No telemetry.&lt;/em&gt;
&lt;em&gt;No vendor lock-in.&lt;/em&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;🔐PAM authentication (&lt;code&gt;login&lt;/code&gt;, &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;polkit&lt;/code&gt;, &lt;code&gt;display managers&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;🧠Offline facial recognition &lt;em&gt;(LBPH, OpenCV)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;⚙️systemd-managed daemon lifecycle&lt;/li&gt;
&lt;li&gt;📷 Webcam support via OpenCV&lt;/li&gt;
&lt;li&gt;🧪Built-in testing via &lt;code&gt;pamtester&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Simple CLI for users and admins&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Architecture&lt;/h2&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/shekh-2810/AstraLock" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;/h2&gt;

&lt;h2&gt;
  
  
  The Problem with Existing Approaches
&lt;/h2&gt;

&lt;p&gt;Most existing solutions (like Howdy) work — until they don’t.&lt;/p&gt;

&lt;p&gt;Common issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PAM inconsistencies across &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;login&lt;/code&gt;, and display managers&lt;/li&gt;
&lt;li&gt;unreliable camera handling&lt;/li&gt;
&lt;li&gt;fragile integration with system components&lt;/li&gt;
&lt;li&gt;limited control over the authentication pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The biggest issue wasn’t the ML part — it was &lt;strong&gt;system integration&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Design Goals
&lt;/h2&gt;

&lt;p&gt;Before writing code, I defined strict constraints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No cloud dependencies&lt;/li&gt;
&lt;li&gt;No telemetry&lt;/li&gt;
&lt;li&gt;Deterministic PAM behavior&lt;/li&gt;
&lt;li&gt;Clean separation between authentication logic and ML&lt;/li&gt;
&lt;li&gt;Works across CLI and GUI authentication flows&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  High-Level Architecture
&lt;/h2&gt;

&lt;p&gt;Instead of embedding everything inside PAM, I separated concerns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application (sudo / login / GUI)
        ↓
       PAM
        ↓
pam_facelock.so
        ↓
facelockd (systemd service)
        ↓
UNIX socket IPC
        ↓
Face recognition pipeline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this design?
&lt;/h3&gt;

&lt;p&gt;PAM modules should stay &lt;strong&gt;minimal and predictable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Heavy operations like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;camera access&lt;/li&gt;
&lt;li&gt;model inference&lt;/li&gt;
&lt;li&gt;image processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;are handled by a separate daemon.&lt;/p&gt;

&lt;p&gt;This avoids blocking PAM and improves reliability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Recognition Pipeline
&lt;/h2&gt;

&lt;p&gt;The pipeline uses modern ONNX-based models:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Face detection (RetinaFace)&lt;/li&gt;
&lt;li&gt;Face alignment (landmark-based)&lt;/li&gt;
&lt;li&gt;Embedding generation (ArcFace, 512-dim)&lt;/li&gt;
&lt;li&gt;Cosine similarity for matching&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything runs locally.&lt;/p&gt;

&lt;p&gt;No external APIs. No network calls.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Challenges
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. PAM Behavior is Subtle
&lt;/h3&gt;

&lt;p&gt;The biggest issue was handling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;auth sufficient&lt;/code&gt; vs &lt;code&gt;required&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;fallback to password authentication&lt;/li&gt;
&lt;li&gt;inconsistent behavior across services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Small changes in PAM configuration can completely change outcomes.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Display Managers Are Inconsistent
&lt;/h3&gt;

&lt;p&gt;GDM, SDDM, and others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;handle authentication differently&lt;/li&gt;
&lt;li&gt;sometimes retry unexpectedly&lt;/li&gt;
&lt;li&gt;may break assumptions about flow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This required testing across environments.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Camera Reliability
&lt;/h3&gt;

&lt;p&gt;Accessing &lt;code&gt;/dev/video*&lt;/code&gt; sounds simple — but:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;permissions vary&lt;/li&gt;
&lt;li&gt;devices differ&lt;/li&gt;
&lt;li&gt;latency can affect authentication timing&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4. Avoiding Lockouts
&lt;/h3&gt;

&lt;p&gt;Biometric authentication is probabilistic.&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;password fallback is always preserved&lt;/li&gt;
&lt;li&gt;PAM is configured as &lt;strong&gt;sufficient, not exclusive&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Current Capabilities
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Works with &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;login&lt;/code&gt;, and GUI prompts (polkit)&lt;/li&gt;
&lt;li&gt;Fully offline inference&lt;/li&gt;
&lt;li&gt;Local model storage per user&lt;/li&gt;
&lt;li&gt;systemd-managed daemon&lt;/li&gt;
&lt;li&gt;CLI for enrollment and verification&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;This is not meant to replace passwords entirely.&lt;/p&gt;

&lt;p&gt;Important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;biometric matching is probabilistic&lt;/li&gt;
&lt;li&gt;spoofing is a real concern&lt;/li&gt;
&lt;li&gt;fallback authentication is required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system is designed for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;convenience + controlled risk, not absolute security&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;System integration is harder than ML&lt;/li&gt;
&lt;li&gt;PAM is powerful but unforgiving&lt;/li&gt;
&lt;li&gt;Reliability matters more than accuracy&lt;/li&gt;
&lt;li&gt;Simplicity in design reduces failure cases&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Looking for Feedback
&lt;/h2&gt;

&lt;p&gt;I’m particularly interested in input on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PAM edge cases in real-world deployments&lt;/li&gt;
&lt;li&gt;failure modes I might be missing&lt;/li&gt;
&lt;li&gt;biometric authentication tradeoffs on Linux&lt;/li&gt;
&lt;li&gt;ways to improve reliability without sacrificing usability&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Project
&lt;/h2&gt;

&lt;p&gt;AstraLock is open source and still evolving.&lt;/p&gt;

&lt;p&gt;If you’ve worked with PAM, Linux auth, or system-level tooling, I’d appreciate your perspective.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
