Running Codex CLI on My Home Linux Server (Ubuntu + SSH Setup)

My home Linux server had been sitting idle for a while after I moved it out of reach, this is mainly to stop my little boy from constantly turning it on and off.

Recently, I’ve been experimenting with Codex in VS Code, and it got me thinking… why not bring that same experience to my home server?

So I decided to install the Codex CLI on my Ubuntu machine.


Installing Codex CLI

I started with:

npm i -g @openai/codex

But I immediately hit a familiar issue:

Command 'npm' not found, but can be installed with:
sudo apt install npm

Looks like I’ve not installed Node.js

So I went ahead and installed npm:

sudo apt install npm

Hitting a Permissions Issue

After installing npm, I tried again but ran into a permissions error:

EACCES: permission denied, mkdir '/usr/local/lib/node_modules'

This happens because global npm installs require access to system directories.

Since I just wanted to get things running quickly on my home server, I reran the install with sudo:

sudo npm i -g @openai/codex

That did the trick.


Running Codex CLI

After installation, I ran:

codex

This immediately prompted me to sign in.


Signing In from a Headless Server (SSH)

Since I’m connected to the server via SSH (no browser access), I selected the option to sign in with a device code.

Codex then provided:

  • A link
  • A one-time code

I opened the link on my laptop. At that point, I had to first enable device authorization for Codex in my ChatGPT security settings.

After enabling it, I entered the code provided in the terminal and the authentication completed successfully.

Simple and actually very smooth once you understand the flow.

Join the ConversationLeave a reply

Your email address will not be published. Required fields are marked *

Comment*

Name*

Website