Run NinjaSurfer on a Linux server
On Linux, browsers are driven by code: the SDK, the command line or an AI agent over MCP. One command installs the ninjasurfer tool. Then start profiles on the server and connect to them.
Install
curl -fsSL https://cdn.cf.surfer.ninja/assets/get/install.sh | bash
If cdn.cf.surfer.ninja is not reachable from your network, use cdn.sl.surfer.ninja:
curl -fsSL https://cdn.sl.surfer.ninja/assets/get/install.sh | bash
- Runs on 64-bit Linux with glibc: Debian, Ubuntu, Fedora, Arch and their relatives. Alpine (musl) is not supported.
- The tool goes to
~/.local/bin(NINJASURFER_BIN_DIRsets another folder). Nothing reaches that folder until its signature checks out. - The system packages the browsers need are installed for you on apt, dnf and pacman systems: only the missing ones, with
sudoonly when needed. Without root or sudo, the installer prints the exact command. In an image that installs them itself,NINJASURFER_SKIP_DEPS=1skips this step.
First run
- Sign in with an API key from the NinjaSurfer app (Settings → API keys):
ninjasurfer login --keyasks for it, or setNINJASURFER_API_KEYfor the process. - Download the browser:
ninjasurfer fetch - Create a profile:
ninjasurfer profile create shop-1 --persona-os mac - Start it:
ninjasurfer start shop-1 --headless --jsonprints the profile'scdpEndpointand holds it open until Ctrl-C.
Starting profiles needs an active plan, the same as in the app.
Drive it
Playwright or any CDP client
Connect to the cdpEndpoint that ninjasurfer start printed:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(CDP_ENDPOINT)
page = browser.contexts[0].new_page()
page.goto("https://example.com")AI agents
ninjasurfer mcp is an MCP server on stdio: profiles, start and stop, and browser tools. ninjasurfer mcp config CLIENT prints an agent's configuration; see the MCP docs.
Sandbox and network stack
Some hosts restrict unprivileged user namespaces (Ubuntu 23.10 and later). There the browser needs NinjaSurfer's sandbox helper, installed once by root after the first fetch:
sudo "$(command -v ninjasurfer)" system install sandbox --cache-dir "$HOME/.cache/ninjasurfer"
--cache-dir names the cache of the account that runs the browsers; change it if you set NINJASURFER_CACHE_DIR. Without it, sudo looks in root's cache and downloads the browser again.
A profile of another system (Windows, macOS, Android or iPhone) on a direct connection needs the network stack, so the connection itself looks like the profile's operating system: sudo "$(command -v ninjasurfer)" system install netstack. Without it such a start is refused. Through a proxy or a VPN the profile starts without it. ninjasurfer system status shows what is installed.
Sizing
Size for the pages you load at once, not for the number of open profiles: CPU runs out before memory.
Downloads and cache
Browsers and fonts are cached per machine. On a host whose disk is reset between runs, point NINJASURFER_CACHE_DIR at a persistent volume.
For many machines, run ninjasurfer fetch once into an image or a shared volume and point NINJASURFER_FONT_PACKS_DIR at the fonts. A new machine then downloads nothing.