# Your first Codex session with Mons

> Install the Host and app, start Codex on your computer, then open the same terminal session from your iPhone or iPad.

The [illustrated tutorial](https://mons.cc/getting-started.html) has separate Host and App chapters. A host is the computer that runs your tools. A persistent session keeps those tools running while you switch screens. Keep the host awake and online.

The tutorial includes real Mac settings, host terminal, and iPhone Simulator captures. The Mac labels are translated into English. Phones use precise control-area crops. Screenshots appear inline and do not open a larger image when tapped.

Numbered markers identify controls. Host names, network addresses, and SSH login details use example values. The pairing capture retains its original expired QR code and link.

The Codex captures use isolated tmux sessions, with SSH for App access. The installer diagram remains labeled as an illustration.

## 1. Prepare your host

Complete this chapter on your Mac or Linux computer.

### 1.1 Install Mons Host

Use a Mac running macOS 13+ or a Linux x86_64/arm64 computer. Linux needs a non-root user and an available systemd user manager.

On a Mac, press Command + Space, type Terminal, then press Return. On Linux, open your terminal application.

Run as your normal user, without sudo:

```sh
curl -fsSL https://mons.cc/install.sh | sh
```

Wait for installation to finish. Open a new Terminal window so it loads the command's installed path. Check the version there:

```sh
mons --version
```

Press Return. Then check the Host:

```sh
mons status
```

Press Return. If a command fails, retain its exact output. Read [download verification](https://mons.cc/guide.html#verify-downloads) if installation is blocked. Do not bypass verification.

Continue when `mons --version` prints a version and `mons status` reports the installed Host.

### 1.2 Enable SSH access

Installing Mons does not enable SSH.

On macOS:

1. Open System Settings → General → Sharing.
2. Click the information button beside Remote Login.
3. Enable Remote Login in the dialog.
4. Check Allow access for. Your login user must be allowed. If Only these users is selected and your user is missing, click +, select your user, then click Select.

Leave other settings unchanged for this tutorial. The screenshots show real macOS 15.8.1 settings with English labels. See [Apple's Remote Login instructions](https://support.apple.com/guide/mac-help/allow-a-remote-computer-to-access-your-mac-mchlp1066/15.0/mac/15.0).

On Linux, enable your distribution's OpenSSH server and allow your login user. See [SSH setup](https://mons.cc/guide.html#ssh-service).

Record the host's public SSH fingerprints in a host Terminal window:

```sh
for host_key in /etc/ssh/ssh_host_*_key.pub; do
  ssh-keygen -lf "$host_key"
done
```

Keep the key types and SHA256 fingerprints available for later verification. Do not share private key files.

### 1.3 Start Codex in a Mons session

Codex runs on your computer with your own account. Mons provides terminal access to that session.

If Codex is not installed, follow [official Codex CLI setup](https://developers.openai.com/codex/cli/). Its macOS/Linux standalone installer is:

```sh
curl -fsSL https://chatgpt.com/codex/install.sh | sh
```

Use the host Terminal where `mons status` succeeded. Press Return after each command.

1. Open the Mons session named work:

   ```sh
   mons open work
   ```

2. In the opened session window, start Codex:

   ```sh
   codex
   ```

This is your Codex window. The session is named work. Complete Codex sign-in if requested. Type this first task at its prompt and press Return:

```text
Create an index.html page with the heading "Hello from Mons". Explain what you changed.
```

Review any approval requested by Codex. Keep this Terminal window open. If `mons help` does not list `open`, check [CLI capabilities](https://mons.cc/guide.html#cli-reference) before continuing.

Continue when Codex responds to the task inside the Mons session.

Run `mons open work` again from another host Terminal to return to this session.

### 1.4 Generate a pairing code

Leave the Codex window open. Open another Terminal window on the same host. On macOS, press Command + N while Terminal is active. On Linux, use the terminal application's New Window action. This is your pairing window. Run this command there and press Return:

```sh
mons pair
```

Keep this command running while you complete the App chapter. The Terminal should show a QR code and pairing link. Both are one-time access information. Keep them private. To replace an expired code, run `mons pair` again in this host Terminal.

The Host chapter is complete when SSH is enabled, fingerprints are saved, Codex runs in a Mons session, and the pairing window shows a code. Keep the Codex window and pairing window open.

## 2. Use the app

Complete this chapter on your iPhone or iPad.

### 2.1 Install the app

1. Install [Apple TestFlight](https://apps.apple.com/app/testflight/id899247664) on your iPhone or iPad.
2. On that device, open the [Mons invitation](https://testflight.apple.com/join/QrKBvj5S).
3. Tap Accept, then Install. Open Mons after installation.

TestFlight shows compatibility and current invitation availability.

### 2.2 Add a connection

1. In Mons, tap Add Connection or the + beside Connections.
2. Choose Easy Pair with QR, then Scan QR Code.
3. Allow camera access if requested. Point the camera at the prepared QR code.
4. Keep Mons open until it returns to the home screen.

Without a camera, paste the host's pairing link into Pairing Link, then tap Add Pairing Link. Use a current pairing code and keep it private.

The devices do not need the same Wi-Fi. A saved connection still requires working SSH for terminal access.

Continue when your computer appears under Connections. Its name can differ from the example's Demo Mac.

### 2.3 Open your session and continue Codex

1. On the Mons home screen, find Connections. Tap your computer's name. The example uses Demo Mac.
2. If Verify Host Identity appears, compare the key type and fingerprint with your saved host fingerprints. Choose Trust Host & Connect only after they match.
3. Wait for work under Existing Sessions. Tap it to open its terminal.
4. Confirm the terminal shows the Codex task from the Host chapter. Tap the keyboard button at the bottom right.

Tap the Codex input prompt. Type the following request, then tap Return on the keyboard:

```text
Add a short sentence below the heading.
```

Success means the same Codex session responds to the phone's new request. Tap the back arrow at the top left to return to Mons. The persistent session continues. To return, tap your connection and select work again.

Stopping the session ends its processes, including Codex. Keep the host awake and online.

## Help

Stop at the first step whose expected result does not appear. Keep the exact error message. Use the [troubleshooting guide](https://mons.cc/guide.html#help) or [report an issue](https://github.com/venjiang/mons.cc/issues/new/choose).
