SecureShell (Alpha)
A "sudo for LLMs" - drop-in shell execution wrapper that prevents hallucinated/destructive commands through AI-powered gatekeeping.
Table of Contents
- Installation
- Quick Start
- Security Templates
- Features
- Configuration
- Challenge Mode
- Providers
- Integrations
- Customizing Rules
Installation
pip install secureshell
Quick Start
See examples/quickstart.py for a complete, production-ready example using OpenAI.
# 1. Set your API Key
export OPENAI_API_KEY=sk-...
# 2. Run the Quickstart Agent
python examples/quickstart.py
What happens?
- The Agent asks to list files (or whatever you prompt it to do).
- SecureShell intercepts the command.
- Green Tier commands (like
ls,dir) run immediately. - Yellow/Red Tier commands (like
rm,git push) trigger the Gatekeeper LLM. - The command runs (or is blocked) and output is returned to the Agent.
Security Templates
No YAML configuration required! Use pre-built security templates for common use cases:
from secureshell import SecureShell
# Choose a template that fits your use case
shell = SecureShell(template="paranoid") # 🔒 Maximum security
shell = SecureShell(template="development") # 🛠️ Local dev friendly
shell = SecureShell(template="production") # 🏭 Production safe
shell = SecureShell(template="ci_cd") # 🚀 CI/CD optimized
Template Quick Reference
| Template | Best For | Allowlist Highlights | Blocklist Highlights |
|---|---|---|---|
| 🔒 paranoid | Untrusted agents | ls, pwd, echo, cat |
rm, dd, chmod, sudo, curl, wget |
| 🛠️ development | Local development | git, npm, pip, node, python |
dd, mkfs, sudo |
| 🏭 production | Production systems | ls, pwd, echo, cat |
rm, dd, chmod, sudo, mkfs |
| 🚀 ci_cd | CI/CD pipelines | git, npm, pip, docker, node |
dd, mkfs, sudo |
📖 Full documentation: examples/SECURITY_TEMPLATES.md
🎯 Try it: Run python examples/templates_demo.py to see all templates in action.
Features
- Risk Tiers: Regex-based instantaneous classification (Green/Yellow/Red).
- Gatekeeper LLM: Uses a separate LLM call to evaluate intent and safety for risky commands.
- Challenge Mode: Gatekeeper can request clarification for ambiguous commands (ALLOW/DENY/CHALLENGE).
- Security Templates: Pre-built configurations for common use cases (paranoid, development, production, ci_cd).
- YAML Configuration: Customize allowlist/blocklist rules via
secureshell.yaml. - Multi-Provider Support: OpenAI, Anthropic, Gemini, DeepSeek, Groq, Ollama, llama.cpp.
- Framework Integrations: OpenAI tools, LangChain, LangGraph, and Anthropic MCP.
- Sandboxing: Prevents directory traversal (
..) and restricts access to allowed paths. - Audit Logging: JSONL logs of every attempt, reasoning, and decision.
For detailed configuration and usage, see the sections below.
Configuration
YAML Configuration
SecureShell supports YAML-based configuration via a secureshell.yaml file in your working directory. This allows you to customize allowlist and blocklist rules without modifying code.
Example Configuration
allowlist:
- "echo"
- "ls"
blocklist:
- "rm"
- "dd"
See examples/config_test.py for a demonstration.
How It Works
- Allowlist: Command types (first word) matching these patterns bypass ALL security checks (including risk tiers and gatekeeper). Use with extreme caution!
- Blocklist: Command types matching these patterns are immediately blocked, regardless of risk tier or reasoning.
- Pattern Matching: Extracts the command type (first word) and matches exactly. For example,
"rm"in the blocklist will blockrm file.txt,rm -rf /, etc.
Environment Variables
SecureShell can be configured via environment variables with the SECURESHELL_ prefix:
SECURESHELL_OPENAI_API_KEY(orOPENAI_API_KEY) - API key for OpenAI providerSECURESHELL_ANTHROPIC_API_KEY(orANTHROPIC_API_KEY) - API key for Anthropic providerSECURESHELL_GEMINI_API_KEY(orGEMINI_API_KEY) - API key for Google GeminiSECURESHELL_DEBUG_MODE- Enable verbose debugging output (true/false)SECURESHELL_PROVIDER- Default provider to use (openai, anthropic, gemini, ollama, etc.)
Programmatic Configuration:
You can also configure OS information programmatically:
shell = SecureShell(
template="production",
os_info="Windows 11 Enterprise" # Tell the gatekeeper what OS you're on
)
The os_info parameter helps the LLM gatekeeper make OS-specific decisions (e.g., knowing that dir is Windows equivalent of ls).
See secureshell/config.py for all available options.
Challenge Mode
SecureShell's gatekeeper can return three decision types:
- ALLOW - Command is safe and will be executed
- DENY - Command is rejected due to safety concerns
- CHALLENGE - Gatekeeper needs more information or clarification
When CHALLENGE is Returned
The gatekeeper returns CHALLENGE when:
- Reasoning provided is vague or unclear
- Intent is ambiguous or missing context
- More information is needed to make a safe decision
- The scope of the command is uncertain
Example
See examples/challenge_demo.py for a full demonstration.
Providers
SecureShell supports multiple LLM providers for the gatekeeper. All providers implement the same interface, making it easy to switch between them.
Supported Providers
Cloud-Based
- OpenAI - GPT-4.1, GPT-4.1-mini, GPT-5.2
- Anthropic - Claude Sonnet 4.5, Claude Haiku 4.5
- Google Gemini - Gemini 2.5 Flash, Gemini 2.5 Flash Lite
- DeepSeek - DeepSeek models (OpenAI-compatible)
- Groq - Fast inference (OpenAI-compatible)
Local Models
- Ollama - Easiest local setup (llama3.1, mistral, codellama, etc.)
- llama.cpp - Maximum control for advanced users
Quick Provider Examples
# OpenAI
from secureshell.providers.openai import OpenAI
provider = OpenAI(api_key="sk-...", model="gpt-4.1-mini")
# Anthropic
from secureshell.providers.anthropic import Anthropic
provider = Anthropic(api_key="sk-ant-...", model="claude-sonnet-4-5")
# Google Gemini
from secureshell.providers.gemini import Gemini
provider = Gemini(api_key="AIza...", model="gemini-2.5-flash")
# Ollama (local)
from secureshell.providers.ollama import Ollama
provider = Ollama(model="llama3.1", base_url="http://localhost:11434")
# llama.cpp (local)
from secureshell.providers.llama_cpp import LlamaCpp
provider = LlamaCpp(model="llama-3.1-8b", base_url="http://localhost:8080")
# Use with SecureShell
shell = SecureShell(provider=provider)
For detailed provider examples, see examples/providers/.
Integrations
SecureShell integrates with popular LLM frameworks and tools:
OpenAI Function Calling
from secureshell import SecureShell
from secureshell.providers.openai import OpenAITools
tools = [OpenAITools.get_tool_definition()]
# Pass 'tools' to your OpenAI client...
LangChain
from secureshell import SecureShell
from secureshell.integrations.langchain import SecureShellTool
# Create tool
shell_tool = SecureShellTool(provider=...)
# Use with LangChain agents
See examples/langchain_example.py for details.
LangGraph
SecureShell works seamlessly with LangGraph for multi-agent workflows.
See examples/langgraph_example.py for a complete example.
Anthropic MCP (Claude Desktop)
To use SecureShell with Claude Desktop:
- Install with MCP extras:
pip install secureshell[anthropic]
- Configure
claude_desktop_config.json:{ "mcpServers": { "secureshell": { "command": "python", "args": ["-m", "secureshell.integrations.mcp"] } } }
See MCP.md for detailed setup instructions.
Customizing Rules
Risk Tiers
Commands are automatically classified into risk tiers:
- GREEN: Auto-allow (ls, pwd, echo)
- YELLOW: Gatekeeper review (rm, git push)
- RED: Strict review (rm -rf, sudo)
- BLOCKED: Always deny (dd, mkfs, fork bombs)
Metadata
Release files for secureshell 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| secureshell-0.2.0.tar.gz | 72.8 kB | Without provenance | Details for secureshell-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| secureshell-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for secureshell-0.2.0-py3-none-any.whl |
Total release size: 111.7 kB
Release files / secureshell-0.2.0.tar.gz
| Download URL | secureshell-0.2.0.tar.gz |
|---|---|
| Size | 72.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ee2be4874384fe9bb217c9a75b2dc0ebc5bda0ecfac31b03246ec8cacbb2a73
|
|
BLAKE2b-256 checksum How to use checksums |
b75a5e2c8c7b31dbbab27b5572166430cb5400a49b85dbb06803bbdafcd00220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / secureshell-0.2.0-py3-none-any.whl
| Download URL | secureshell-0.2.0-py3-none-any.whl |
|---|---|
| Size | 39.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fec2e0c7bf81180776bce3c8afb38b094274553a8c821772152a8613c8a3f268
|
|
BLAKE2b-256 checksum How to use checksums |
3a15594c22128f961dff42165a692acfa4d905df2149355dddcf175a75ac6af5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for secureshell 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.