# Run as Root - safe one-command sudo for AI agents

> Your agent runs one command as root through the Linux desktop's own polkit dialog — you approve the exact command, and it never sees your password.

Run as Root - safe one-command sudo for AI agents is a free AI agent skill on Agensi by R Govarthenan, in DevOps & Cloud. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [R Govarthenan](https://www.agensi.io/creators/r-govarthenan)
- Category: [DevOps & Cloud](https://www.agensi.io/skills/devops-cloud)
- Uses: 2
- Version: 1.0
- Last updated: 2026-10-10
- Security: scan passed (2026-10-10); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/run-as-root-safe-one-command-sudo-for-ai-agents
- Tags: devops, security, automation, linux, polkit, sudo

## About this skill

### The problem
Coding agents constantly hit commands that need root — `apt install`, `systemctl`, writing to `/etc`. The usual answers are all bad:

- **Give the agent your password** (`sudo -S`, an askpass script) — the agent now holds your password.
- **Passwordless sudo** (`NOPASSWD`) — the agent has permanent, invisible root.
- **Stop and make you run it** — breaks your flow, and you paste commands without reading them.

### What it does
`run-as-root` gives the agent a fourth option: escalate **one** command at a time through your desktop's own polkit password dialog.

- The dialog shows the agent's stated reason **and the true command line**.
- You type your password into the operating system's prompt — never into the agent.
- The password travels polkit's own path (authentication agent → `polkit-agent-helper-1` → `polkitd`). No part of the agent's code touches it.
- Every run is written to the `authpriv` audit log with the full command.

### Why this beats the alternatives
| Method | Problem | run-as-root |
|---|---|---|
| Password to the agent | Agent holds your secret | Agent never sees it |
| NOPASSWD sudo | Permanent, invisible root | One command, one dialog, logged |
| Hand it back to you | Breaks flow; blind paste | You approve the exact command inline |

### Use cases
- Let an agent install build dependencies, drivers, or packages mid-task.
- Approve `systemctl`, `mount`, `usermod`, or writes to `/etc`, `/usr`, `/opt`.
- Keep a full, reviewable audit trail of everything an agent ran as root.

### Known limitations
- **Linux desktop only** (X11 or Wayland) with a running polkit agent.
- Tested on Linux Mint 22.3 / Cinnamon / polkit 124; other desktops and distros use standard polkit and should work, but are untested.
- **Not for** headless servers, SSH, containers, CI, cron, WSL, macOS or Windows — the skill detects these and hands the command back instead.
- You must already be an administrator (`sudo`/`admin`/`wheel`). It grants **no new privilege** — the same power as `sudo`, and not more.

### How to install
1. Add the skill: `npx skills add govarthenan/run-as-root`
2. Install the system helper yourself, in your own terminal: `sudo bash ~/.claude/skills/run-as-root/install.sh`
3. Remove anytime: `sudo bash ~/.claude/skills/run-as-root/uninstall.sh`

MIT licensed. Author: Govarthenan Rajadurai.

## Requires

- Node.js

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Run as Root - safe one-command sudo for AI agents skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill handle root passwords without compromising my security?

This skill eliminates 'broken terminal' errors by offloading authentication to the OS. It uses the native Linux polkit dialog to securely prompt you for your password on the desktop, preventing the AI from hanging on hidden sudo prompts or seeing your sensitive credentials.

### Can I use 'run as root' on a remote server or through SSH?

This skill is designed specifically for local Linux desktop environments (X11 or Wayland) that utilize polkit. It is not compatible with Windows, macOS, or remote sessions like SSH and Docker, as it requires a local graphical user session to trigger the password dialog.

### What exactly is included in the purchase of this skill?

You will receive the 'run-as-root' helper script, the core agent skill logic, and a setup guide. The package includes everything needed to bridge your AI agent's commands to the system's native authentication framework.

### What does the installation process look like for a new user?

Setup requires a one-time manual installation of the provided helper script on your Linux machine. Once installed, your AI agent will be able to detect the script and use it to trigger secure escalations automatically whenever a task requires root privileges.

### Which AI agents or frameworks are supported by this skill?

The skill is designed to be framework-agnostic and works with any AI agent capable of executing local shell commands. It has been tested for compatibility with common agent architectures that support custom tool calling or external script execution.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
