Privileged Access Management (PAM) for OpenClaw - Chat-based sudo approval workflows with biometric authentication
Hybrid PAM System for OpenClaw
KingCrab provides secure, chat-based approval workflows for elevated commands. Instead of giving agents sudo access, they submit requests that humans approve via Telegram with biometric authentication.
KingCrab uses a hybrid architecture:
Agent → Plugin Tool → HTTP → Daemon (Go) → Database
↓
OpenClaw Webhook
↓
Telegram Notification
↓
Biometric Approval → Execute
kingcrab database# Clone repository
git clone https://github.com/KHAEntertainment/kingcrab.git
cd kingcrab
# Build daemon
go build -o kingcrab ./cmd/kingcrab
# Run installer (requires sudo)
sudo ./installer/install.sh
# Set database password
sudo systemctl edit kingcrab
# Add: [Service]
# Environment="KINGCRAB_DB_PASSWORD=your_password"
# Start service
sudo systemctl start kingcrab
sudo systemctl enable kingcrab
# Verify
curl http://localhost:8080/api/v1/health
# Create database and user
sudo -u postgres createuser kingcrab
sudo -u postgres createdb -O kingcrab kingcrab
# Set password
sudo -u postgres psql -c "ALTER USER kingcrab PASSWORD 'your_password';"
# Run migrations (daemon does this automatically on first start)
# Or manually:
psql -U kingcrab -d kingcrab -f /usr/local/share/kingcrab/migrations/001_pam_schema.sql
# Copy to OpenClaw extensions
mkdir -p ~/.openclaw/extensions/kingcrab
cp -r plugin/* ~/.openclaw/extensions/kingcrab/
# Install dependencies
cd ~/.openclaw/extensions/kingcrab
npm install
# Build
npm run build
Edit ~/.openclaw/openclaw.json:
{
"extensions": {
"kingcrab": {
"enabled": true,
"daemonUrl": "http://localhost:8080"
}
}
}
# Via OpenClaw skill
/kc enroll
# Follow prompts in Telegram to authorize device
The plugin registers these tools for agents:
kingcrab_requestCreate a privileged command request requiring approval.
Input:
command (string, required): The command to executereason (string, optional): Explanation for why this command is neededExample:
{
"command": "apt install golang-go",
"reason": "Need Go for building CLI tool"
}
Response:
{
"success": true,
"request": {
"id": "abc123...",
"status": "pending",
"expires_at": "2026-03-19T12:35:00Z"
},
"message": "Request created: abc123. Waiting for approval via Telegram..."
}
kingcrab_listList all KingCrab elevation requests, optionally filtered by status.
Input:
status (string, optional): Filter by status (pending, approved, denied, completed, failed, expired)Example:
{
"status": "pending"
}
kingcrab_getGet details of a specific KingCrab request by ID.
Input:
id (string, required): The request IDkingcrab_request tool/etc/kingcrab/config.json{
"version": "1.0.0",
"listen": {
"type": "tcp",
"port": 8080
},
"allowedCommands": [
"apt install *",
"apt update",
"systemctl restart *",
"systemctl start *",
"systemctl stop *",
"systemctl status *"
],
"requireReason": true,
"openclaw": {
"webhookUrl": "http://localhost:3000/api/kingcrab/notify",
"enabled": true
}
}
~/.openclaw/openclaw.json{
"extensions": {
"kingcrab": {
"enabled": true,
"daemonUrl": "http://localhost:8080",
"timeout": 10000
}
}
}
| Layer | Protection |
|---|---|
| Daemon Isolation | Runs as root via systemd, separate from agent |
| Database Persistence | All requests logged with audit trail |
| Command Allowlist | Only pre-approved commands can execute |
| Biometric 2FA | Telegram biometric auth required for approvals |
| Request Expiration | Pending requests expire after 5 minutes |
| Privilege Separation | Plugin never has root access, only daemon does |
# Check logs
sudo journalctl -u kingcrab -n 50
# Check database connection
psql -U kingcrab -d kingcrab -c "SELECT 1;"
# Verify config
sudo kingcrab --check-config
# Check OpenClaw logs
tail -f ~/.openclaw/openclaw.log
# Verify plugin structure
ls -la ~/.openclaw/extensions/kingcrab/
# Check config
cat ~/.openclaw/openclaw.json | jq '.extensions.kingcrab'
# Check daemon logs for notification errors
sudo journalctl -u kingcrab -f | grep notify
# Verify webhook URL
sudo cat /etc/kingcrab/config.json | jq '.openclaw.webhookUrl'
Create a new elevation request.
List all requests (with optional filters).
Get details of a specific request.
Approve a request with biometric authentication.
Deny a request.
Health check endpoint.
MIT
KHAEntertainment