All Projects → nullpo-head → Wsl Hello Sudo

nullpo-head / Wsl Hello Sudo

Licence: mit
Let's sudo by face recognition of Windows Hello on Windows Subsystem for Linux (WSL). It runs on both WSL 1 and WSL 2. This is a PAM module for Linux on WSL.

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Wsl Hello Sudo

ubuntu-win-bootstrap
DEPRECIATED! Use "linux-comfy-chair" instead. A very simple bootstrap script to install some development tools to the Windows 10 Ubuntu Bash system - Ruby, Perl, Python, Node, Sublime Text and more!
Stars: ✭ 27 (-94.36%)
Mutual labels:  wsl
Fedora Remix For Wsl
Fedora Remix for Windows Subsystem for Linux.
Stars: ✭ 284 (-40.71%)
Mutual labels:  wsl
Lnmp
💻 🐳 🐘 🐬 🐧 🚀 Start Docker LNMP(LEMP) In less than 2 minutes Powered by Docker Compose. 让 PHP 开发者快速(一键)搭建基于容器技术(Docker、Kubernetes)的开发、测试、生产(CI/CD by Drone)环境.
Stars: ✭ 341 (-28.81%)
Mutual labels:  wsl
wsl2exe
[TESTING]Use command in WSL from exe executable
Stars: ✭ 34 (-92.9%)
Mutual labels:  wsl
Weasel Pageant
Deprecated: An ssh-agent compatible helper for interacting with Pageant from processes running on the Windows Subsystem for Linux.
Stars: ✭ 256 (-46.56%)
Mutual labels:  wsl
Wsl Ssh Agent
Helper to interface with Windows ssh-agent.exe service from Windows Subsystem for Linux (WSL)
Stars: ✭ 298 (-37.79%)
Mutual labels:  wsl
wsl-agent-bridge
WSL compatibility bridge for ssh-agent on Windows
Stars: ✭ 17 (-96.45%)
Mutual labels:  wsl
Move Wsl
Easily move your WSL distros VHDX file to a new location.
Stars: ✭ 389 (-18.79%)
Mutual labels:  wsl
Vimplus
🚀An automatic configuration program for vim
Stars: ✭ 3,372 (+603.97%)
Mutual labels:  wsl
Wsl Terminal
Terminal emulator for Windows Subsystem for Linux (WSL)
Stars: ✭ 3,120 (+551.36%)
Mutual labels:  wsl
dotfiles
Dotfiles & Developer Environment. Supports Ubuntu2004+, macOS Catalina+, Windows 10 w WSL
Stars: ✭ 30 (-93.74%)
Mutual labels:  wsl
gitwrap
Windows Wrapper for Linux git executable
Stars: ✭ 77 (-83.92%)
Mutual labels:  wsl
My Wsl Setup
Quick rundown on my current setup on the Windows Subsystem for Linux.
Stars: ✭ 298 (-37.79%)
Mutual labels:  wsl
nvim-ghost.nvim
👻 GhostText plugin for Neovim with zero dependencies 🎉 Supports neovim running inside WSL too! 🥳 Windows/Linux/macOS supported out-of-the-box! 😄 (Other OSes need python3.6+ installed)
Stars: ✭ 32 (-93.32%)
Mutual labels:  wsl
Perl5 Idea
Perl5 plugins for IntelliJ IDEA
Stars: ✭ 343 (-28.39%)
Mutual labels:  wsl
WSL-Distro-Rootfs
Install anyrootfs as a WSL Instance (for Windows 10 FCU 64bit or later) [WSL-DistroLauncher](https://github.com/yuk7/WSL-DistroLauncher)
Stars: ✭ 22 (-95.41%)
Mutual labels:  wsl
Awesome Wsl
Awesome list dedicated to Windows Subsystem for Linux
Stars: ✭ 3,544 (+639.87%)
Mutual labels:  wsl
Dotfiles
Settings for various tools I use.
Stars: ✭ 513 (+7.1%)
Mutual labels:  wsl
Wsl Ssh Pageant
A Pageant -> TCP bridge for use with WSL, allowing for Pageant to be used as an ssh-ageant within the WSL environment.
Stars: ✭ 381 (-20.46%)
Mutual labels:  wsl
Wsl Open
Open files with xdg-open on Bash for Windows in Windows applications. Read only mirror from GitLab, see link 👉
Stars: ✭ 299 (-37.58%)
Mutual labels:  wsl

WSL Hello sudo

"WSL Hello sudo" is a Linux PAM module and companion Windows CLI apps that realize sudo by biometric login of Windows Hello on Windows Subsystem for Linux (WSL).
This PAM module allows you to authenticate sudo via face recognition, fingerprint authentication, and of couse machine-local PIN. It runs in both WSL and WSL 2.

The Linux PAM module is written in Rust, and Windows CLI apps are written in C#.
Please use it at your own risk. There is no warranty.

demo

"WSL Hello sudo" actually does not modify your sudo command at all. It is a Linux PAM module.
PAM, Plaggable Authentication Module, is a UNIX's module system that provides user authentication mechanisms to applications such as sudo or su. "WSL Hello sudo" is such a PAM module that lets applications use Windows Hello.

Installation and Configuration

Installation

The installation process is very simple.
Please download the latest release package from GitHub Release and unpack it.
Run install.sh inside the directory, and follow the instruction of install.sh

$ wget http://github.com/nullpo-head/WSL-Hello-sudo/releases/latest/download/release.tar.gz
$ tar xvf release.tar.gz
$ cd release
$ ./install.sh

Although you don't have to care about the detailed installation process,
install.sh does following things.

  1. Copy small Windows CLI apps that launch Windows Hello to C:\Users\your_account\pam_wsl_hello (default location)
  2. Install a PAM module to your WSL system.
  3. Create config files in /etc/pam_wsl_hello/
  4. Create uninstall.sh

Configuration

"WSL Hello sudo" is not a fork of sudo but a PAM module. So please configure /etc/pam.d/sudo to make it effective.
I strongly recommend to set password of root first so that you can switch to it by su, in case you make some typo in the config of sudo.
Add auth sufficient pam_wsl_hello.so to the top line of your /etc/pam.d/sudo like the following example

#%PAM-1.0

auth       sufficient pam_wsl_hello.so
session    required   pam_env.so readenv=1 user_readenv=0
session    required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
@include common-session-noninteractive

Even if you fail to authenticate via Windows Hello, sudo moves on to the regular password authentication by this setting with sufficient.

Other applications that authenticate users such as su can also utilize Windows Hello by this module.
Even so, I strongly recommend you to make either sudo or su free from this module to prevent from being locked out

Troubleshooting

Windows Hello window appears in background.

The Windows Hello dialog sometimes appears in background. In some cases, it even fails to recognize your face with some weird error message. It seems a bug of Windows API. In that case, restarting Windows a couple of times might solve the problem.

"Windows Hello is not invoked! sudo just prompts password!"

Maybe some error is happening. Unfortunately, sudo suppresses error messages from PAM modules.
To debug "WSL Hello sudo", make it effective for su instead of sudo. su shows error messages from PAM modules, so you can see what is going on.

For your information, the setting for su will be like the example below. I will show only relevant two lines.

auth       sufficient pam_rootok.so
auth       sufficient pam_wsl_hello.so  

Build

The Linux PAM module of "WSL Hello sudo" is written in Rust, and the Windows CLI apps are written in C#.
So, cargo and Visual Studio are required to build it.

Before building "WSL Hello sudo", add the path to MSBuild.exe to PATH environment variable of bash on WSL, not Windows.
If you build Windows CLI apps with your Visual Studio GUI, you can ignore that. In my environment, MSBuild lives in /mnt/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/

To build "WSL Hello sudo", just run make.

$ git clone https://github.com/nullpo-head/WSL-Hello-sudo.git
$ cd WSL-Hell-sudo
$ make

It invokes cargo and MSBuild.exe properly.

Whether you're using bash or Windows, the repository must be in the Windows filesystem, otherwise MSBuild.exe won't work.

Internals

Windows Hello maintains RSA key-pairs for each Windows user in its TPM hardware, and tells success of authentication by signing given contents by the private key. To utilize its API, "WSL Hello sudo" contains small Windows CLI apps that return public key and singned signature of given content. On the other hand, the PAM module of "WSL Hello sudo" remembers the public keys of each Windows user who corresponds to each Linux user. So, the PAM module authenticates the given Linux user by the following process.

  1. The PAM module is launched by sudo and receives a Linux user to be authenticated
  2. The PAM module launches the companion Windows app and sends a random value via WSL's interop bridge
  3. The companion Windows app invokes Windows Hello
  4. Windows Hello makes a signature of the given input by the private key of the current Windows user
  5. The companion Windows app returns the signature
  6. The PAM module verifies the signature by the public key of the Windows user who corresponds to the given Linux user.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].