How to Use ChatGPT Codex CLI When Your Server Has No Browser

Stuck trying to authenticate ChatGPT Codex CLI on a remote server with no browser? Here’s the simple SSH port forwarding trick that solves it in minutes.

AI Generated image for the article

Today I ran into a problem I bet a lot of developers face. I wanted to use the ChatGPT Codex CLI on a headless Linux server that I access through SSH. Copying and pasting code between the server and ChatGPT on my desktop was getting old fast, so the Codex CLI seemed like the perfect solution.

The installation itself? Pretty straightforward. The CLI gives you two authentication options: use an OpenAI API token or connect through ChatGPT. Here’s the thing — the API token costs money based on usage. But since I’m already paying for ChatGPT Plus, going the ChatGPT route is basically free. Plus, I get those higher usage limits that come with the subscription.

Now here’s where things got interesting. I use Google to log into my OpenAI account. This means the Codex CLI needs to open a browser so I can authenticate with Google and authorize the tool. Pretty standard stuff — except my remote server doesn’t have X, a graphical interface, or even a web browser. Kind of a problem.

The Solution: Local Browser, Remote…

Leave a Reply