Codex CLI #
ubuntu server 使用 codex cli #
ssh config 配置代理 #
vim ~/.ssh/config
Host hhht-211
HostName 1.180.13.251
User root
IdentityFile ~/.ssh/id_rsa
Port 211
# 代理
RemoteForward 127.0.0.1:1080 127.0.0.1:1080
本地电脑的 127.0.0.1:1080 有 http 代理,可以科学上网(访问 openai codex)
部署配置 #
ssh 登录远程服务器
# apt update
# apt install npm -y
npm i -g @openai/codex
cat << 'EOF' >> ~/.bashrc
alias codex='http_proxy=http://127.0.0.1:1080 https_proxy=http://127.0.0.1:1080 codex'
EOF
. ~/.bashrc
vscode ssh remote 使用 codex 插件 #
cd "$(dirname "$(which codex)")"
# 首次已备份过就不会再动;若没备份过会备份
[ -f codex.real ] || mv codex codex.real
cat > codex <<'SH'
#!/usr/bin/env bash
# —— HTTP 代理在 127.0.0.1:1080 ——
# 同时设置大/小写 + ALL_PROXY,最大兼容性(HTTPS 也会通过 HTTP CONNECT)
export HTTP_PROXY="http://127.0.0.1:1080"
export HTTPS_PROXY="http://127.0.0.1:1080"
export ALL_PROXY="http://127.0.0.1:1080"
export http_proxy="${HTTP_PROXY}"
export https_proxy="${HTTPS_PROXY}"
export all_proxy="${ALL_PROXY}"
# 不走代理的直连目标
export NO_PROXY="localhost,127.0.0.1,::1"
export no_proxy="${NO_PROXY}"
exec "$(dirname "$0")/codex.real" "$@"
SH
chmod +x codex
叶王 © 2013-2024 版权所有。如果本文档对你有所帮助,可以请作者喝饮料。