NinjaSurfer Docs / Linux servers ← Back to the site
Docs · Linux servers

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

bash
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:

bash
curl -fsSL https://cdn.sl.surfer.ninja/assets/get/install.sh | bash

First run

  1. Sign in with an API key from the NinjaSurfer app (Settings → API keys): ninjasurfer login --key asks for it, or set NINJASURFER_API_KEY for the process.
  2. Download the browser: ninjasurfer fetch
  3. Create a profile: ninjasurfer profile create shop-1 --persona-os mac
  4. Start it: ninjasurfer start shop-1 --headless --json prints the profile's cdpEndpoint and 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:

python
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:

bash
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.