Give Codex SSH Access To Remote Devices

guide2026-06-0211 min read

Codex can operate remote machines safely and repeatably once your local computer can SSH to them through stable aliases such as ssh macmini and ssh vps.

sshtailscalecodexremote-access

Summary

This guide shows how to let Codex access your remote Mac, VPS, or Linux machine through SSH without sharing passwords in normal use. The final state is simple: from the computer where Codex runs, commands like ssh macmini and ssh vps should log in directly, and Codex can then inspect files, run commands, deploy services, or debug logs on those machines. The clean setup uses three layers: Tailscale for private networking, SSH keys for authentication, and ~/.ssh/config aliases for readable host names. If a proxy app breaks Tailscale routes, add an explicit route for the Tailscale device or configure the proxy to exclude the Tailscale network.

What This Solves

Codex can only SSH to machines that the local computer can already reach. If you want Codex to manage a remote Mac mini, a VPS, or a self-hosted server, first make the local shell able to run commands like this:
ssh macmini 'whoami; hostname; pwd'
ssh vps 'whoami; hostname; pwd'
Once those work, Codex can use the same aliases. This avoids pasting passwords repeatedly, avoids exposing public ports unnecessarily, and gives you a stable workflow for future remote operations.

Who This Is For

This is for someone starting from zero who wants an AI coding agent running on their laptop to access remote devices over SSH. You do not need deep networking knowledge. You do need enough control over each target machine to enable SSH, install Tailscale if needed, and add one SSH public key to the right user’s authorized_keys file.

Prerequisites

  • A local computer where Codex runs, such as a MacBook.
  • A remote target, such as a Mac mini, Ubuntu VPS, or other Linux server.
  • Tailscale installed and logged in on the local computer and each remote target.
  • SSH enabled on each target.
  • A local SSH key such as ~/.ssh/id_ed25519.
  • Admin access on the local computer if you need to fix proxy route conflicts.
Never paste private keys into chat or store passwords in notes. Share only public keys, such as ~/.ssh/id_ed25519.pub. If you typed a real password during setup, change it after SSH key login works.

The Workflow

1

Create or confirm a local SSH key

On the local computer where Codex runs, check whether an SSH key already exists:
ls -la ~/.ssh
If there is no id_ed25519 key, create one:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "codex-remote-access"
The private key stays local at ~/.ssh/id_ed25519. The public key is safe to copy:
cat ~/.ssh/id_ed25519.pub
2

Enable SSH on a remote Mac

On the remote Mac, open:
System Settings -> General -> Sharing -> Remote Login
Turn on Remote Login. If macOS asks who may connect, choose the specific local macOS account that Codex should use. For example, if the account is demo, the SSH command will look like this:
ssh demo@100.80.10.20
The username is the macOS login account on the remote Mac, not the name of your laptop.
3

Enable SSH on a VPS

Most Linux VPS images already run OpenSSH. If not, install and start it from the VPS console:
sudo apt update
sudo apt install -y openssh-server
sudo systemctl enable --now ssh
sudo systemctl status ssh
Confirm the intended login user. Common examples are ubuntu, debian, root, or a custom user such as demo.
4

Connect all devices with Tailscale

Install Tailscale on the local computer and every remote target. Log them into the same tailnet.On a Linux VPS, a typical install is:
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
On macOS, install the Tailscale app, sign in, and copy the target’s Tailscale IPv4 address. Tailscale addresses usually look like:
100.80.10.20
100.90.20.30
These are private tailnet addresses. They are not normal public internet IPs.
5

Test raw SSH before creating aliases

From the local computer, test each device directly:
ssh demo@100.80.10.20
ssh demo@100.90.20.30
If SSH asks whether to trust the host key, type yes. If it asks for a password, enter the password for that remote user one time.Then verify identity:
whoami
hostname
pwd
exit
6

Install the local public key on the remote target

After one password login works, add the local public key to the remote user. The manual method is:
cat ~/.ssh/id_ed25519.pub
Copy the full output line, then on the remote machine append it to:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Or use this one-command pattern from the local machine, replacing the user and IP:
ssh demo@100.90.20.30 'umask 077; mkdir -p ~/.ssh; touch ~/.ssh/authorized_keys'
cat ~/.ssh/id_ed25519.pub | ssh demo@100.90.20.30 'cat >> ~/.ssh/authorized_keys'
After this, a password should no longer be needed.
7

Create readable SSH aliases

Edit the local SSH config:
nano ~/.ssh/config
Add aliases like this:
Host macmini
  HostName 100.80.10.20
  User demo
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

Host vps
  HostName 100.90.20.30
  User demo
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes
Now the important commands are short and memorable:
ssh macmini
ssh vps
8

Verify that Codex can use the aliases

In the same local environment where Codex runs, test non-interactively:
ssh -o BatchMode=yes -o ConnectTimeout=8 macmini 'whoami; hostname; pwd'
ssh -o BatchMode=yes -o ConnectTimeout=8 vps 'whoami; hostname; pwd'
A good result looks like:
demo
example-mac-mini.local
/Users/demo
or:
demo
example-vps
/home/demo
If those commands pass, Codex can access the targets through SSH.

Common Failure Modes

Permission denied (publickey,password) means the network path reached SSH, but the remote account does not trust the local public key yet. Add ~/.ssh/id_ed25519.pub to the remote user’s ~/.ssh/authorized_keys.
Operation timed out usually means a routing or firewall problem. First test the port:
nc -vz -w 8 100.90.20.30 22
If the port does not open, verify Tailscale is connected on both machines and SSH is running on the target.
Proxy and VPN apps can steal Tailscale routes. If opening a proxy app makes ssh macmini fail, check where the Tailscale IP is routed:
route -n get 100.80.10.20
The route should use the Tailscale interface, often named utun4 on macOS. If it goes through a normal Wi-Fi gateway such as en0, the proxy is overriding the tailnet route.
For proxy clients such as Shadowrocket, do not assume that a rule like IP-CIDR,100.64.0.0/10,DIRECT will hand traffic back to Tailscale. In some clients, DIRECT means “send through the physical network interface,” which can still bypass Tailscale. Prefer a real excluded route or bypass setting for 100.64.0.0/10.
If the proxy client cannot exclude Tailscale routes cleanly, add a temporary host route on macOS:
sudo route add -host 100.80.10.20 -interface utun4
sudo route add -host 100.90.20.30 -interface utun4
Replace utun4 with the actual Tailscale interface from ifconfig or your route table. This fix can disappear after rebooting, reconnecting VPNs, or restarting Tailscale.
Tailscale uses the 100.64.0.0/10 address range. Example tailnet IPs such as 100.80.10.20 and 100.90.20.30 are sample values for teaching. Use the actual Tailscale IPs shown in your Tailscale app or admin console.

Final Checklist

  • The local computer has an SSH key at ~/.ssh/id_ed25519.
  • Each remote target has SSH enabled.
  • Each remote target is connected to the same Tailscale network.
  • The local public key is in the remote user’s ~/.ssh/authorized_keys.
  • ~/.ssh/config has aliases such as macmini and vps.
  • ssh -o BatchMode=yes macmini 'whoami; hostname; pwd' works.
  • ssh -o BatchMode=yes vps 'whoami; hostname; pwd' works.
  • If a proxy app is running, Tailscale target IPs still route through the Tailscale interface.

What To Remember

Codex does not need a special remote-access product. It needs the local shell to have reliable SSH access. The durable pattern is:
Tailscale private IP -> SSH key authentication -> ~/.ssh/config alias -> Codex uses ssh alias
When troubleshooting, separate the problem into layers. nc or ssh -vvv tells you whether the port is reachable. Permission denied means authentication. Operation timed out means routing, firewall, or service availability. route -n get tells you whether a proxy app has stolen the path away from Tailscale.

Metadata

Quick Reference

Typeguide
Statuspublished
Date2026-06-02

Retrieval Tags

sshtailscalecodexremote-access
Related
SSH key managementTailscale routingRemote Codex workflows