A simple cross-platform CLI tool written in Rust that authenticates users against the system PAM (Pluggable Authentication Modules) stack.
pam_auth is a small binary that takes a username and password as command-line arguments and checks them using PAM β just like how login, sudo, or sshd authenticate users.
β
Works with system accounts
β
Supports any PAM backend (e.g. LDAP, shadow, 2FA)
β
Does not require root privileges to run
pam_auth <username> <password>Example:
pam_auth edwin secret123Returns:
- Exit code
0: β Authentication successful - Exit code
2: β Authentication failed
- Rust
libpamdevelopment headers (Linux/FreeBSD)
cargo build --release
./target/release/pam_auth username passwordWe use cross to compile for other OS targets:
cross build --release --target x86_64-unknown-linux-gnu
cross build --release --target x86_64-unknown-freebsdOutputs:
target/x86_64-unknown-linux-gnu/release/pam_auth
target/x86_64-unknown-freebsd/release/pam_auth
To test the binary:
./pam_auth root wrongpass # Should fail
./pam_auth root correctpass # Should succeed (if root password is known)Note: For security, run only in secure, trusted environments.