Centralized browser infrastructure for multiple AI agents. Each agent gets their own isolated Chrome instance that runs on a shared server, accessible via SSH tunnel. Perfect for teams where agents need browsers but you want to monitor, assist, and manage them centrally.
┌─────────────────────────────────────────────────────────────┐
│ Remote Server (vm2.junod.dev) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Chrome:9222 │ │ Chrome:9223 │ │ Chrome:9224 │ │
│ │ (Agent: dev1)│ │ (Agent: dev2)│ │ (Agent: dev3)│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Admin Monitor - View/takeover any agent browser │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
▲
SSH Tunnels │ SSH Tunnels
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌────▼────┐ ┌────▼────┐ ┌────▼────┐
│ Agent 1 │ │ Agent 2 │ │ Agent 3 │
│(dev1) │ │(dev2) │ │(dev3) │
└─────────┘ └─────────┘ └─────────┘
On the remote server (e.g., vm2.junod.dev):
cd remote-playwright
# Initialize the multi-agent server
./scripts/server-manager.sh init
# Install Playwright (if not already installed)
npm install
npx playwright install chromiumAs admin on the server:
# Start a browser for agent "dev1"
./scripts/server-manager.sh start dev1
# Start browsers for multiple agents
./scripts/server-manager.sh start dev2
./scripts/server-manager.sh start dev3
# See all running browsers
./scripts/server-manager.sh listOutput shows:
- Port assigned to the agent (e.g., 9222)
- SSH command for the agent to connect
- CDP URL for programmatic access
Each agent runs on their local machine:
cd remote-playwright
# Connect using their assigned agent name
AGENT_NAME=dev1 ./scripts/agent-connect.sh
# Or set it in environment
export AGENT_NAME=dev1
./scripts/agent-connect.shThis will:
- Find their assigned port on the server
- Create an SSH tunnel to that port
- Verify the browser connection
- Keep the tunnel open
As admin, you can view and help any agent:
# List all agents and their browsers
./scripts/admin-monitor.sh list
# Take a screenshot of dev1's browser
./scripts/admin-monitor.sh screenshot dev1
# View dev1's browser via VNC (if visual display enabled)
./scripts/admin-monitor.sh view dev1
# Execute JavaScript in dev1's browser
./scripts/admin-monitor.sh exec dev1 "document.title"
# Navigate dev1's browser (to help them)
./scripts/admin-monitor.sh navigate dev1 https://example.com
# Interactive menu mode
./scripts/admin-monitor.sh interactiveHere's the workflow for agents who need to log into services securely:
# On server
./scripts/server-manager.sh start alice
# Output shows: Port 9222 assigned# On Alice's machine
AGENT_NAME=alice ./scripts/agent-connect.sh
# Tunnel created, browser accessible at localhost:9222# On server (or via admin-monitor)
./scripts/admin-monitor.sh navigate alice https://auth.openai.com/...# Alice connects VNC to see the browser
vncviewer vm2.junod.dev:5900
# Enters her credentials (admin cannot see them)# Alice uses her local tools with the authenticated browser
agent-browser --cdp 9222 snapshot
# Or Playwright, etc../scripts/server-manager.sh <command> [args]
Commands:
init Create directories and setup
start <agent-name> Start browser for agent
stop <agent-name> Stop browser for agent
stop all Stop all browsers
list List all running browsers
status Show server overview
Environment Variables:
SERVER_NAME Server hostname (default: vm2.junod.dev)
BASE_PORT Starting port (default: 9222)
MAX_AGENTS Max concurrent agents (default: 10)
DATA_DIR Where agent profiles are stored./scripts/agent-connect.sh [command]
Commands:
connect Connect to assigned browser (default)
check Quick status check
help Show help
Environment Variables:
SERVER_NAME Server to connect to
AGENT_NAME Your agent identifier./scripts/admin-monitor.sh <command> [args]
Commands:
list List all agents
view <agent> View browser via VNC
screenshot <agent> Take screenshot
exec <agent> <script> Execute JavaScript
navigate <agent> <url> Navigate to URL
interactive Interactive menuimport { chromium } from 'playwright';
const CDP_PORT = process.env.CDP_PORT || 9222;
const CDP_URL = `http://localhost:${CDP_PORT}`;
async function run() {
// Connect to your assigned browser
const browser = await chromium.connectOverCDP(CDP_URL);
// Get the existing page (already authenticated maybe)
const context = browser.contexts()[0];
const page = context.pages()[0];
// Do your work
await page.goto('https://platform.openai.com');
// ... automation tasks ...
await browser.close();
}import { chromium } from 'playwright';
async function monitorAgent(agentName, agentPort) {
const browser = await chromium.connectOverCDP(`http://localhost:${agentPort}`);
const page = browser.contexts()[0]?.pages()[0];
// Take screenshot for monitoring
await page.screenshot({ path: `monitor-${agentName}.png` });
// Check what they're doing
const url = page.url();
const title = await page.title();
console.log(`${agentName}: ${title} (${url})`);
await browser.close();
}Create a .env file on the server:
# Server configuration
SERVER_NAME=vm2.junod.dev
BASE_PORT=9222
MAX_AGENTS=20
DATA_DIR=/opt/chrome-agents
# For agents (on their local machines)
SERVER_NAME=vm2.junod.dev
AGENT_NAME=$(whoami)Add to ~/.ssh/config on agent machines:
Host vm2.junod.dev
HostName vm2.junod.dev
User your-username
IdentityFile ~/.ssh/id_rsa
ServerAliveInterval 30
ServerAliveCountMax 3
-
SSH Key Authentication Only
- Disable password auth on the server
- Use strong SSH keys
-
Firewall Rules
# On server - only allow localhost access to Chrome ports sudo iptables -A INPUT -p tcp --dport 9222:9232 -s 127.0.0.1 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 9222:9232 -j DROP -
VNC Password Protection
# Set VNC password instead of -nopw x11vnc -storepasswd MySecurePass ~/.vnc/passwd x11vnc -rfbauth ~/.vnc/passwd ...
-
Separate Agent Profiles Each agent gets their own Chrome profile (
--user-data-dir), so:- Cookies/logins are isolated
- Extensions don't leak between agents
- Storage is separate
-
Regular Cleanup
# Stop inactive browsers ./scripts/server-manager.sh stop all # Clean up old profiles rm -rf ~/.chrome-agents/dev1
# Check if browser is running on server
ssh vm2.junod.dev "curl -s http://localhost:9222/json/version"
# Check if port is assigned to agent
ssh vm2.junod.dev "cat ~/.chrome-agents/pids/dev1_port"
# Check SSH tunnel on agent's machine
lsof -Pi :9222 -sTCP:LISTEN# Verify you're on the server
hostname # Should show vm2.junod.dev
# Check if agent's browser is running
./scripts/admin-monitor.sh list
# Test direct connection
curl http://localhost:9222/json/version# Find what's using the port
lsof -Pi :9222 -sTCP:LISTEN
# Kill it or use a different port for the agent
./scripts/server-manager.sh stop dev1
./scripts/server-manager.sh start dev1 # Will get next available port# Check if VNC is running
netstat -tlnp | grep 5900
# Restart VNC
pkill x11vnc
x11vnc -display :99 -forever -shared -nopw -rfbport 5900The system automatically finds the next available port:
# dev1 gets 9222
./scripts/server-manager.sh start dev1
# dev2 gets 9223
./scripts/server-manager.sh start dev2
# dev3 gets 9224
./scripts/server-manager.sh start dev3Agent data persists across restarts:
# Alice's browser with all her logins
./scripts/server-manager.sh start alice
# She logs in...
./scripts/server-manager.sh stop alice
# Later - her session is still there
./scripts/server-manager.sh start alice
# Still logged in!For very large teams, run multiple servers:
# Server 1: Ports 9222-9231
SERVER_NAME=browser1.company.com MAX_AGENTS=10 ./scripts/server-manager.sh init
# Server 2: Ports 9232-9241
SERVER_NAME=browser2.company.com BASE_PORT=9232 MAX_AGENTS=10 ./scripts/server-manager.sh init# Admin checks all agent browsers
./scripts/admin-monitor.sh list
# Quick screenshot of each
for agent in dev1 dev2 dev3; do
./scripts/admin-monitor.sh screenshot $agent
echo "Screenshot saved for $agent"
done# Agent says: "Something weird is happening"
# Admin views their browser
./scripts/admin-monitor.sh view dev1
# Or takes a screenshot to see what's wrong
./scripts/admin-monitor.sh screenshot dev1
# Can even navigate for them to a working page
./scripts/admin-monitor.sh navigate dev1 https://working-site.com# 1. Admin creates browser
./scripts/server-manager.sh start newdev
# 2. Share connection info with newdev
# Port: 9225
# SSH: ssh -N -L 9225:localhost:9225 vm2.junod.dev
# 3. Newdev runs on their machine
AGENT_NAME=newdev ./scripts/agent-connect.sh
# 4. Newdev uses the browser!
agent-browser --cdp 9225 open https://example.comIf you're currently using a single shared browser:
# 1. Stop the old shared browser
pkill -f 'chrome.*9222'
# 2. Initialize multi-agent system
./scripts/server-manager.sh init
# 3. Start individual browsers for each user
./scripts/server-manager.sh start alice
./scripts/server-manager.sh start bob
./scripts/server-manager.sh start charlie
# 4. Each person connects with their own tunnel
# Alice: AGENT_NAME=alice ./scripts/agent-connect.sh
# Bob: AGENT_NAME=bob ./scripts/agent-connect.sh
# etc.Built with:
- Playwright - Browser automation
- agent-browser - CLI tool for browser control
- Chrome DevTools Protocol (CDP) - Remote debugging interface