doas

Crates.iodoas
lib.rsdoas
version0.1.0
created_at2026-01-16 08:06:45.967096+00
updated_at2026-01-16 08:06:45.967096+00
descriptionA Rust implementation of doas, a minimal sudo alternative with PAM authentication
homepagehttps://github.com/hkwk/doas
repositoryhttps://github.com/hkwk/doas
max_upload_size
id2048149
size17,360
Kunlun Huang (hkwk)

documentation

https://docs.rs/doas

README

doas

A Rust implementation of doas, an alternative to sudo for running commands as other users.

Features

  • Simple configuration file syntax
  • Supports permit/deny rules with options like nopass, keepenv
  • PAM authentication
  • Unix-like systems only

Installation

  1. Build the project:

    cargo build --release
    
  2. Install the binary:

    sudo cp target/release/doas /usr/local/bin/
    sudo chown root:root /usr/local/bin/doas
    sudo chmod 4755 /usr/local/bin/doas
    
  3. Create config file:

    sudo mkdir -p /usr/local/etc
    sudo cp doas.conf.sample /usr/local/etc/doas.conf
    sudo chown root:root /usr/local/etc/doas.conf
    sudo chmod 600 /usr/local/etc/doas.conf
    
  4. Edit the config file to add rules, e.g.:

    permit yourusername as root
    

Usage

doas command [args...]
doas -u user command [args...]

Configuration

The config file is located at /etc/doas.conf or /usr/local/etc/doas.conf.

Syntax:

permit [nopass] [keepenv] [nolog] identity as target
  • permit or deny
  • nopass: no password required
  • keepenv: keep environment variables
  • nolog: don't log
  • identity: the user who can run
  • target: the user to run as

Security

The binary must be setuid root to function properly. Ensure the config file is only readable by root.

Commit count: 0

cargo fmt