Zero-dependency, cross-platform GUI sudo frontend — lets AI Coding Agents safely execute privileged commands in the background.

What Problem Does This Solve?

AI Agents running in non-root terminals need sudo for privileged operations — but sudo requires an interactive tty for password input. The agent’s subprocess has no tty. Result: command fails, agent deadlocks, or hallucinates.

gsudo inserts a GUI confirmation layer between the agent and the system: the agent calls gsudo, the user confirms and enters credentials via a graphical window, the command runs as root, and the output returns to the agent.

Core Design

stdout/stderr Separation

stdout → raw command output (AI can parse directly)
stderr → gsudo banner + status (human-readable)

When the agent runs gsudo whoami with capture_output=True, stdout is simply root. No regex-parsing wrapper text required.

Why Custom Tkinter Instead of pkexec

gsudo (sudo -S + Tkinter)pkexec
Command preview✅ Full command + AI-generated reason shown❌ Not customizable
Cross-platform✅ Linux/macOS/Windows❌ Linux only
Environment variables✅ Fully preserved❌ Strictly sanitized
DependenciesZero (Python stdlib)Requires PolicyKit

sudo -S reads the password from stdin pipe — subprocess.run passes it directly. gsudo itself runs without root privileges.

Cross-Platform Adaptation

LinuxmacOSWindows
Privilege mechanismsudo -Ssudo -SStart-Process -Verb RunAs
GUI interactionPassword fieldPassword fieldConfirm button
System dialogNoneNoneUAC (secure desktop, cannot bypass)
Password❌ (UAC is intent confirmation, not auth)

On Windows, PowerShell commands are base64-encoded to prevent injection.

Multi-Instance Concurrency

No global lock. Multiple agents needing privilege simultaneously get simultaneous dialogs — the user decides which to handle first. A lock would leave later instances hanging in the terminal.

No Password Caching

sudo has its own timestamp — gsudo adds no extra caching. Privilege escalation should always require explicit user confirmation.

Tech Stack

  • Python 3.6+
  • Tkinter (ttk) — standard library, zero install
  • Linux/macOS: sudo -S stdin password pipe
  • Windows: PowerShell + base64 encoding → UAC

Quick Start

# Dependency (Linux only)
sudo apt install python3-tk

# Install
curl -o ~/.local/bin/gsudo https://raw.githubusercontent.com/CNCSMonster/gsudo/main/scripts/gsudo
chmod +x ~/.local/bin/gsudo

# Register as Agent Skill
ln -sf /path/to/gsudo ~/.agents/skills/gsudo

Verification Status

PlatformStatus
Linux✅ Verified on real hardware
macOS❌ No device
Windows❌ No desktop environment