Complete Workflow for Using Codex CLI on AutoDL
This Skill helps users use Codex CLI directly on AutoDL remote servers to modify and debug project code, avoiding the need to download remote projects and large data to local machines. It is suitable for the following scenarios:
- Your code and data are on the AutoDL remote server;
- Data files are too large to download locally;
- You want Codex to directly read remote code, modify files, and run tests;
- The AutoDL server cannot directly access
chatgpt.comorapi.openai.com; - You encounter network, npm, PATH, gawk, SHA checksum issues when installing Codex CLI.
1. Overall Approach
Do not download the project from AutoDL to your local machine and then let Codex modify it. Instead:
- Open an SSH reverse proxy on your local computer;
- Let AutoDL access OpenAI through the local proxy;
- Install Codex CLI on the AutoDL server;
- Run
codexdirectly in the AutoDL project directory; - Let Codex read, modify, and run code directly on the remote server.
The ultimate goal is:
cd /autodl-tmp/your-project-directory
codex
2. Get the AutoDL SSH Address and Port
Find the SSH login command for the current instance in the AutoDL console.
The format is usually similar to:
ssh -p 32384 [email protected]
Where:
[email protected]
is the AutoDL address;
-p 32384
is the SSH port.
In all subsequent commands, replace <PORT> with the port, e.g., 32384; replace <HOST> with the address, e.g., connect.bjb2.seetacloud.com.
3. Open an SSH Reverse Proxy on Your Local Computer
If your local computer already has Clash, VPN, or another proxy running, and the local proxy port is 7890, run the following in local Windows PowerShell, CMD, or Git Bash:
ssh -N -R 7890:127.0.0.1:7890 -p <PORT> root@<HOST>
Example:
ssh -N -R 7890:127.0.0.1:7890 -p 32384 [email protected]
Enter the AutoDL SSH password.
Note:
- When entering the password, the terminal will not display any characters, nor
*; - Paste the password and press Enter;
- If login succeeds, the window will hang (this is normal);
- Do not close this window; it maintains the tunnel from AutoDL to the local proxy.
If you see:
Permission denied
The password is incorrect. Go back to the AutoDL console to copy the correct SSH password.
4. Set Proxy Environment Variables on AutoDL
Open another terminal, SSH into AutoDL normally, or use the AutoDL web terminal.
Once on AutoDL, run:
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
Then test the network:
curl -I https://chatgpt.com
curl -I https://api.openai.com
If before you got:
Connection timed out
And now you get:
HTTP/1.1 200 Connection established
The proxy tunnel is now active.
If accessing chatgpt.com returns:
HTTP/2 403
This usually means the connection to the site was established, but the page itself is blocked by Cloudflare or access policies—it doesn't necessarily indicate proxy failure. Continue testing the Codex installation script or api.openai.com.
5. Install Codex CLI
On AutoDL, run:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
If successful, you'll see something like:
Installing Codex CLI
Detected platform: Linux (x64)
Resolved version: ...
Installing standalone package ...
Codex CLI installed successfully.
6. Handle gawk / SHA-256 Checksum Errors
If during installation you see:
Could not find SHA-256 digest for codex-package-x86_64-unknown-linux-musl.tar.gz in codex-package_SHA256SUMS.
This is usually because the default awk is not GNU awk, and the installation script fails to parse SHA256SUMS.
First check:
awk --version
If the output is:
awk: not an option: --version
Then your current awk is not GNU awk.
Do not use:
bash awk --version
This is incorrect syntax. awk is a binary program, not a shell script.
Fix it:
apt-get update
apt-get install -y gawk
After installation, check:
gawk --version
awk --version
If awk --version still isn't GNU Awk, switch the default awk:
update-alternatives --install /usr/bin/awk awk /usr/bin/gawk 20
update-alternatives --set awk /usr/bin/gawk
Check again:
awk --version
Once resolved, reinstall Codex:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
7. Handle npm command not found
If you run:
npm install -g @openai/codex
And see:
bash: npm: command not found
Your AutoDL environment does not have Node.js/npm.
You can install it via conda:
conda install -c conda-forge nodejs -y
Check:
node -v
npm -v
Then set npm proxy:
npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890
Then install Codex:
npm install -g @openai/codex
If the official installation script already succeeded, the npm method is not needed.
8. Handle codex command not found
After installation, if you run:
codex --version
But get:
bash: codex: command not found
It's usually because the current terminal's PATH hasn't been refreshed.
First run:
export PATH=/root/.local/bin:$PATH
Then check:
which codex
codex --version
You can also use the full path:
/root/.local/bin/codex --version
To make codex available in every new terminal session, append it to .bashrc:
echo 'export PATH=/root/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Check again:
codex --version
Normally you'll see something like:
codex-cli 0.141.0
9. Log in to Codex
AutoDL is typically a headless environment, so use device authentication:
codex login --device-auth
Codex will display a login link and a one-time code in the terminal.
Open the link in a browser on your local computer, log in to ChatGPT, and enter the code shown in the terminal.
After login, AutoDL will show:
Successfully logged in
Check login status:
codex login status
10. Start Codex in the AutoDL Project Directory
Navigate to the project directory:
cd /autodl-tmp/your-project-directory
Example:
cd /autodl-tmp/Tencent-Advertising-Algorithm-Competition
Start Codex:
codex
Then you can have Codex directly analyze and modify remote code.
Recommended first prompt:
Please first read the code structure of this project, do not read the full dataset. Help me analyze the training pipeline and current possible issues. Do not modify files yet; first provide a modification plan.
If you need it to modify code, say:
Please modify the code based on the analysis just now. Only modify necessary files, do not read the full dataset, do not delete data, weights, or log files. After modification, tell me which files were changed and how to test.
11. Safe Usage Rules for Large Data Projects
AutoDL projects often contain large data, model weights, logs, and experiment results. Before using Codex, it's recommended to create AGENTS.md:
nano AGENTS.md
Write:
# Project Description
This is a machine learning project running on an AutoDL server.
## Important Rules
- Do not read the full dataset.
- Do not open large file directories like data, dataset, checkpoints, outputs, logs unless explicitly requested by the user.
- If you need to check data format, only read the first 5 lines or ask the user for a small sample.
- Before modifying code, first explain which files you plan to modify.
- Do not delete any data files, model weights, logs, or experiment results.
- Do not run full training directly unless explicitly requested by the user.
- Prioritize lightweight tests, syntax checks, or small-sample testing.
Then run:
codex
12. Recommended Full Command Sequence
Local computer: Open reverse proxy
ssh -N -R 7890:127.0.0.1:7890 -p <PORT> root@<HOST>
Keep this window open.
AutoDL server: Set proxy
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
AutoDL server: Test network
curl -I https://chatgpt.com
curl -I https://api.openai.com
AutoDL server: Fix awk
apt-get update
apt-get install -y gawk
AutoDL server: Install Codex
curl -fsSL https://chatgpt.com/codex/install.sh | sh
AutoDL server: Refresh PATH
export PATH=/root/.local/bin:$PATH
echo 'export PATH=/root/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
AutoDL server: Check version
codex --version
AutoDL server: Log in
codex login --device-auth
AutoDL server: Enter project and start
cd /autodl-tmp/your-project-directory
codex
13. Quick Troubleshooting
Issue 1: curl: (28) Failed to connect to chatgpt.com
Cause: AutoDL cannot directly access ChatGPT.
Solution: Open an SSH reverse proxy on your local computer and set proxy environment variables on AutoDL.
Issue 2: Cannot paste SSH password
Cause: SSH password input does not display any characters.
Solution: Paste and press Enter. Only if you see Permission denied is the password wrong.
Issue 3: HTTP/1.1 200 Connection established followed by HTTP/2 403
Cause: The proxy tunnel is working, but the target site rejected the request.
Solution: Continue testing the installation script or api.openai.com—it's not necessarily a proxy failure.
Issue 4: npm: command not found
Cause: Node.js/npm is not installed on AutoDL.
Solution:
conda install -c conda-forge nodejs -y
Issue 5: Could not find SHA-256 digest
Cause: The default awk is not GNU awk, so the installation script fails to parse the SHA checksum file.
Solution:
apt-get install -y gawk
If necessary:
update-alternatives --install /usr/bin/awk awk /usr/bin/gawk 20
update-alternatives --set awk /usr/bin/gawk
Issue 6: bash: codex: command not found
Cause: Codex was installed successfully, but the current shell's PATH hasn't been refreshed.
Solution:
export PATH=/root/.local/bin:$PATH
source ~/.bashrc
Or:
/root/.local/bin/codex --version
Issue 7: Codex login can't open a browser
Cause: AutoDL is a remote headless environment.
Solution:
codex login --device-auth
Complete the device authentication in a browser on your local computer.
14. Usage Principles
When using Codex on AutoDL, follow these principles:
- Set up the proxy first, then use Codex;
- Do not close the local SSH reverse proxy window;
- Do not start Codex in the root directory of large data;
- Prefer starting Codex in the project code directory;
- Use
AGENTS.mdto restrict Codex from reading large data; - Let Codex propose a plan before modifying code;
- Check changes with
git diffafter modifications; - Do not let Codex directly delete data, weights, or experiment results;
- Before full training, have Codex run a small-sample test;
- Every time you reopen an AutoDL terminal, verify that proxy variables and PATH are still set.