Codex login link doesn't work from ssh server
What version of Codex is running?
codex-cli 0.23.0
Which model were you using?
N/A (couldn't get past login)
What platform is your computer?
Linux 6.8.0-71-generic x86_64 x86_64
(its an ubuntu server)
What steps can reproduce the bug?
To reproduce bug:
- connect to ssh server (so no browser available on the box)
- install codex 'sudo npm install -g @openai/codex'
- run 'codex' to trigger setup -> choose to 'Sign in with ChatGPT'
- paste the required link into the browser (browser won't open automatically as this is via ssh the box itself doesn't have a browser)
- You will get the following error:
'Oops, an error occurred!
Route Error (400 Invalid Session): "Your authorization session was not initialized or has expired"'
<img width="633" height="487" alt="Image" src="https://github.com/user-attachments/assets/bcd4f579-796f-47df-a1ac-786a54c63210" />
What is the expected behavior?
I should be able to paste the link into my browser and complete the login.
What do you see instead?
You will get the following error:
'Oops, an error occurred!
Route Error (400 Invalid Session): "Your authorization session was not initialized or has expired"'
<img width="633" height="487" alt="Image" src="https://github.com/user-attachments/assets/030503dd-6076-4eac-bbd5-4b083c882250" />
Additional information
Note: I am a user who logs into chat gpt via the 'login with google' integration, not sure if this is impacting
I have tried from a local session (rather than over ssh) and the link when opened in browser automatically (as my local machine of course has a browser installed) worked fine.
10 Comments
FWIW this morning, I have managed to do to the ssh login with a remote linux box and normally use login with google. Didn't work first time as it probably timed out but on second attempt it worked. This is using 0.23.
Please see https://github.com/openai/codex/tree/main?tab=readme-ov-file#connecting-on-a-headless-machine
Log in to with your local machine. Copy the contents of ~/.codex/auth.json and place the contents in ~/.codex/auth.json in the ssh'd session (where you want to use codex).
Then, run codex normally and it should work. ($CODEX_HOME was not set for me.)
$CODEX_HOMEis assumed to be~/.codexif not set.I see now that's not mentioned in those docs, only https://github.com/openai/codex/blob/main/codex-rs/config.md.
See information above shared by @bolinfest and we'll continue to improve our auth methods and documentation, thank you!
我已经实现了VScode远程链接服务器端的codex,首先需要再服务器端安装Clash verge,打开全局,然后在终端设置nano ~/.bashrc
export http_proxy=http://127.0.0.1:7897
export https_proxy=http://127.0.0.1:7897
export all_proxy=socks5://127.0.0.1:7897
source ~/.bashrc
就可以了,然后就可以在window打开vscode使用ssh连接远程服务器的codex,
does not work been trying for hours to connect my codex cli to my remote ssh vps its so easy with claude code... the tunnel dont even work in cmd in windows. trash.
✅ Workaround: log in to Codex running on a remote server via SSH port forwarding
The login flow usually opens a local URL (e.g.
http://localhost:1455/...). If Codex is running on a remote server, clicking that link on your laptop won’t reach the server’s localhost. Fix: forward the server’s port to your machine, then copy-paste the URL into your local browser.Steps
http://auth.openai...?...)._Linux/macOS:_
ssh -N -L 1455:localhost:1455 root@YOUR_SERVER
_Windows (PowerShell with OpenSSH):_
ssh -N -L 1455:localhost:1455 root@YOUR_SERVER
_PuTTY:_ Connection → SSH → Tunnels → Source port:
1455| Destination:localhost:1455→ Add → Open.http://auth.openai...?...).Do not click it remotely. Paste it into your local browser’s address bar. Thanks to the tunnel, your local
http://localhost:1455now points to the server’slocalhost:1455.Why this works
-L 1455:localhost:1455maps yourlocalhost:1455→ serverlocalhost:1455. The login URL assumes the service is on the same localhost as the browser. The tunnel makes that true from your machine.Tips / Troubleshooting
ss -ltnp | grep 1455
# or:
netstat -tulnp | grep 1455
http://localhost:9000/...):ssh -N -L 9000:localhost:1455 root@YOUR_SERVER
autossh -M 0 -N -L 1455:localhost:1455 root@YOUR_SERVER
ssh -p 2222 -N -L 1455:localhost:1455 root@YOUR_SERVER
@SauersML solution works me. This is a common issue for now remote ssh user. Hope it can implement the auth like geminni-cli or like github authentication.
@chunjie-sam-liu, we have a new feature available (in preview) that is intended to address this use case. For details, refer to this post.