> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lilac-research.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run on a remote machine

> Make a server or cluster login node an environment, and open its projects from your laptop.

This guide outlines how to run projects on a machine that stays on, such as a lab server or a cluster login node. An **environment** is such a machine. It runs `lilac worker`, which dials out to the Lilac server, so it needs no open port.

```mermaid theme={null}
flowchart LR
  a["<b>Your laptop</b><br/>chat, or the app"]:::neutral -->|connects| b["<b>Lilac server</b><br/>relays messages"]:::key
  c["<b>Environment</b><br/>runs agents and projects"]:::plum -->|dials out| b
```

**1. Start a worker on the remote machine**

```bash theme={null}
curl -fsSL https://raw.githubusercontent.com/lukass16/lilac/main/scripts/install.sh | sh
lilac login
lilac worker
```

`lilac login` shows a code to approve in the browser. Keep `lilac worker` running, in tmux or as a long batch job. New projects go in `~/lilac-projects`, which `--projects-root` changes. For a container, mint a token on the website and pass `--token-file <path>`, or set `LILAC_TOKEN_FILE`.

**2. List environments from your laptop**

```console theme={null}
$ lilac login
$ lilac environments
lab-box  machine  online  32 CPUs, 128 GB, 2 GPU  env_8f3a
    /home/me/lilac-projects/demo  open, 1 working
```

**3. Connect to a project**

```console theme={null}
$ lilac connect lab-box ~/lilac-projects/demo --port 4300
/home/me/lilac-projects/demo on lab-box is at ws://127.0.0.1:4300
$ LILAC_CORE_URL=ws://127.0.0.1:4300 lilac chat
```

`connect` runs until Ctrl+C. Agents run on the remote machine and keep working when you disconnect.

> [accordion] Without the Lilac server
>
> An SSH tunnel also works. Run one core under a supervisor on the remote machine and forward its port.
>
> ```bash theme={null}
> lilac worker --project ~/my-project --port 4290   # on the remote machine
> ssh -L 4291:127.0.0.1:4290 remote-host            # on yours
> LILAC_CORE_URL=ws://127.0.0.1:4291 lilac chat
> ```

For every command, see the [CLI reference](https://docs.lilac-research.com/cli/reference/cli.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.