Aident AI

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:
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
tmuxon 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:
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:
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:
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:
Open System Settings > General > Sharing.
Turn on Remote Login.
Allow access only for the account you will use.
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:
If MagicDNS is unavailable, use the 100.x.y.z address printed by tailscale ip -4.
Run three read-only checks:
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:
Install tmux through the host's normal package manager. For example, on Debian or Ubuntu:
Authenticate Codex on the host, preferably while you have local access:
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:
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:
Give Codex a harmless read-only task, such as summarizing one README file.
Detach with
Ctrl-b d.Close the phone's SSH client or briefly switch networks.
Reconnect to the host.
Reattach to the named session:
Success means the same Codex session and prior terminal output are present. Confirm the repository is still clean:
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:
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:
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:
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
Codex CLI, OpenAI, accessed July 31, 2026
OpenAI Codex repository, GitHub, accessed July 31, 2026
Tailscale SSH, Tailscale, accessed July 31, 2026
Install Tailscale on Linux, Tailscale, accessed July 31, 2026
Traditional SSH over Tailscale, Tailscale, accessed July 31, 2026
Allow a remote computer to access your Mac, Apple, accessed July 31, 2026
Getting started with tmux, tmux, accessed July 31, 2026
Codex Remote blocks private-LAN SSH, GitHub, opened August 1, 2026
Codex remote-control feature request, GitHub, opened November 5, 2025
Termius, Tailscale, and tmux mobile workflow, X, published July 29, 2026
What is your Codex workflow like?, Reddit, published July 31, 2026
How to run Claude Code and OpenAI Codex on your mobile, YouTube, published July 26, 2026
Refresh this guide when OpenAI changes Codex Remote networking, Tailscale changes macOS SSH-server support, or either tool changes its authentication and permission model.


