The sudo prompt glared back at me like a locked door. I had the keys, but I didn’t want to leave them lying around for anyone else to find.
Privilege is power. In systems, it’s also risk. Leaving elevated access open is like leaving debug mode on in production—eventually, something goes wrong. Just-In-Time Privilege Elevation in Zsh isn’t just a security tactic. It’s a control plane for when and how power gets unlocked. You grant exactly what’s needed, exactly when it’s needed, and nothing more.
With Zsh, the shell becomes the enforcement layer. Scripts can request temporary privileges for commands, apply strict expiration, log usage, and revoke automatically. This stops the sprawl of permanent sudoers. It closes the gap between least privilege theory and operational reality. The rules are dynamic, so even high-trust users don’t carry high-risk access for longer than a command execution window.
Attack surfaces shrink because credentials aren’t sitting around idle. Insider risk drops because administrative capabilities vanish seconds after the task completes. Compliance teams like it because the audit trail is immediate and precise. Engineers like it because it works inside the flow of a normal terminal session with minimal friction.