Run Codex Remotely From Your Phone With Tailscale and tmux

Run Codex Remotely From Your Phone With Tailscale and tmux

Aident AI

A private luminous connection links a phone to layered terminal sessions on a trusted computer.

Run Codex Remotely From Your Phone With Tailscale and tmux

The safest portable setup is simple: run Codex CLI on a trusted computer, expose that computer only to your private Tailscale network, and keep Codex inside a named tmux session. Your phone becomes a terminal, while the repository, Git credentials, and Codex process stay on the host.

You do not need to open port 22 on your router, copy a repository to your phone, or install API keys there. The complete path is:

phone SSH client -> private Tailscale connection -> trusted host -> tmux -> Codex CLI

This guide uses Tailscale SSH on Linux. On a Mac running the App Store or standalone Tailscale GUI, use macOS Remote Login over the Tailscale address instead. Tailscale documents that those GUI variants cannot act as Tailscale SSH servers.

Prerequisites

You need:

  • a trusted Linux or macOS computer that can stay awake while you work;

  • Tailscale on that host and your phone, signed into the same tailnet;

  • an SSH client on your phone;

  • Codex CLI and tmux on the host;

  • a non-root operating-system account and a repository with a known Git state;

  • local or console access to the host in case an SSH change locks you out.

Record the starting state on the host:

hostname
tailscale status
git -C /absolute/path/to/repo status --short

Expected result: the host appears online in your tailnet, and every local repository change is accounted for. Do not test remote access against uncommitted work you cannot recover.

Step 1: Join Both Devices to the Same Tailnet

Install Tailscale from its official package or app on the host and phone. On a supported Linux host, connect it with:

sudo tailscale up
tailscale status
tailscale ip -4

Expected result: tailscale status lists the host and phone, and tailscale ip -4 prints the host's private 100.x.y.z tailnet address. If MagicDNS is enabled, the host also has a stable tailnet name such as codex-host.

Do not add router port forwarding. Tailscale supplies the private network path, so the SSH service does not need a public internet route.

Step 2: Enable a Narrow SSH Path

Linux: use Tailscale SSH

Keep local recovery access open, then enable Tailscale SSH on the host:

sudo tailscale set --ssh
tailscale status

In the Tailscale admin console, restrict network access and SSH access to your identity, this host, and the non-root account you intend to use. Prefer the check action when you want periodic reauthentication. Use the policy editor's tests before saving a policy change.

Tailscale warns that enabling its SSH server can interrupt an existing SSH connection made over a Tailscale IP. Make this first change from a local terminal or with a second recovery path available.

macOS GUI: use Remote Login over Tailscale

The App Store and standalone Tailscale GUI variants for macOS do not provide the Tailscale SSH server. Instead:

  1. Open System Settings > General > Sharing.

  2. Turn on Remote Login.

  3. Allow access only for the account you will use.

  4. Connect to that Mac's Tailscale IP or MagicDNS name.

This is traditional macOS SSH carried over the private Tailscale network. Do not expose Remote Login with router port forwarding.

Step 3: Prove the Phone Can Reach the Right Host

In the phone's SSH client, connect with your operating-system username and the host's MagicDNS name:

ssh dev@codex-host

If MagicDNS is unavailable, use the 100.x.y.z address printed by tailscale ip -4.

Run three read-only checks:

whoami
hostname
tailscale ip -4

Expected result: whoami shows the intended non-root account, hostname identifies the trusted computer, and the IP matches the host you enrolled. Stop if any value is unexpected.

Step 4: Install Codex and tmux on the Host

Install the current Codex CLI on the host with OpenAI's documented installer:

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

Install tmux through the host's normal package manager. For example, on Debian or Ubuntu:

sudo apt-get update
sudo apt-get install -y tmux
tmux -V

Authenticate Codex on the host, preferably while you have local access:

codex

Complete the documented sign-in flow, then exit. The repository and credentials should remain on the host. The phone only sends terminal input and displays output.

Step 5: Start One Named Codex Session

From the SSH connection on your phone:

cd /absolute/path/to/repo
git status --short
tmux new-session -A -s codex-myproject
codex

tmux new-session -A -s codex-myproject creates the named session if it does not exist and attaches to it if it does. Use a different predictable session name for each repository.

Before assigning work, ask Codex to inspect the repository instructions and report the current Git status. Keep the first task read-only. Expected result: Codex operates in the intended repository and describes the same working-tree state you recorded earlier.

To leave the process running, press Ctrl-b, release both keys, then press d. That detaches your terminal without stopping Codex.

Step 6: Verify That Reconnection Actually Works

Do not assume persistence from a successful first login. Test it:

  1. Give Codex a harmless read-only task, such as summarizing one README file.

  2. Detach with Ctrl-b d.

  3. Close the phone's SSH client or briefly switch networks.

  4. Reconnect to the host.

  5. Reattach to the named session:

tmux attach-session -t codex-myproject

Success means the same Codex session and prior terminal output are present. Confirm the repository is still clean:

git status --short

If a task will make changes, review git diff before accepting them. Remote access does not change the normal rule: use the narrowest permissions that let the task finish, and do not make broad approval modes your default.

Common Failure Modes

SSH Times Out

On both devices, confirm Tailscale is connected to the same tailnet. On the host, run:

tailscale status
tailscale ip -4

For Linux Tailscale SSH, verify that SSH is enabled and that the tailnet access policy permits your source identity, destination host, and login account. On macOS, verify that Remote Login is on for the selected user.

Permission denied Appears

The SSH username is the host's operating-system user, not an email address or Codex account name. Confirm that the Tailscale SSH rule or macOS Remote Login list permits that user. Do not work around the error by allowing every user or logging in as root.

Tailscale SSH Does Not Work on a Mac

Check which Tailscale variant is installed. Tailscale's macOS GUI variants can initiate SSH connections but cannot run the Tailscale SSH server. Keep the GUI app and use macOS Remote Login over the Tailscale address, or move the persistent host to Linux.

no sessions Appears in tmux

Codex was probably started outside tmux, or the host rebooted. Start it with the create-or-attach command:

tmux new-session -A -s codex-myproject
codex

After a host reboot, an in-memory session is gone. Treat Git commits, reviewed patches, and saved files as durable state; tmux is connection persistence, not a backup.

The Host Goes to Sleep

Tailscale and tmux cannot serve a sleeping or powered-off host. Use an always-on Linux machine when unattended availability matters. If you change power settings on a laptop, account for battery, heat, physical security, and your ability to recover the machine.

Codex Reports Operation not permitted for a Private-LAN Command

A current Codex issue documents Remote tasks that cannot open arbitrary private-LAN SSH connections from inside the agent sandbox. That is a different path from the human SSH connection in this guide:

you -> SSH over Tailscale -> host                 works at the host boundary
Codex Remote sandbox -> another private-LAN host separate sandbox egress decision

Do not disable all sandboxing to erase the distinction. Keep human access scoped to the one host. For provider services, use a reviewed integration Action with explicit inputs and approval instead of handing raw credentials or unrestricted network access to the agent.

Why This Setup Works

Tailscale gives the phone and host a private, identity-aware network route without opening a public router port. SSH authenticates the operating-system session. tmux separates the shell process from the phone's temporary connection, so a mobile network switch does not terminate Codex. Codex and the repository remain on the trusted host, which avoids synchronizing source code and credentials onto the phone.

Each layer has one job. That separation also makes failures easier to diagnose: check Tailscale reachability, then SSH identity, then tmux, then Codex.

Preflight One Remote Action Without Putting Its Key on Your Phone

Open Aident Loadout, connect one read-only integration, and use the installed Aident CLI from the remote Codex host to search for a relevant Action, inspect its schema, and run preflight before execution.

The measurable check is: one Action is discovered and preflighted, zero provider writes occur, and no provider credential is copied to the phone or pasted into the Codex prompt. Execute only after you review the exact Action, input, risk, and credit estimate. For the broader setup, read How to Connect Claude Code and Codex to Real-World Tools.

Sources

Refresh this guide when OpenAI changes Codex Remote networking, Tailscale changes macOS SSH-server support, or either tool changes its authentication and permission model.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.