< 自用文儿 在 Ubuntu 上安装 Claude Code > 发现了“京东云 JDCloude” 有国内商业云中最低的网络性能

发布于:2025-06-26 ⋅ 阅读:(18) ⋅ 点赞:(0)

Claude Code:

最近刷屏这个词:Claude Code 以后叫 CC,它是 Anthropic 的一款智能编程工具,几个特点:

  • 在终端运行 像使用命令行工具一样,无需图形用户界面 GUI
  • 深度理解整个代码库 
  • 使用自然语言 让其修复 bug、生成代码、重构代码、甚至运行测试。
  • 代理式编程工具 "Agentic Coding Tool" 提供代码建议,还能直接在你的开发环境中编辑文件并执行命令,实现自动化编程

总而言之,CC 就是在你终端里工作的 AI 助手,能理解你的代码,并依照你给出的自然语言指令,来帮助你完成编写、修改以及调试代码。

可怜的京东云用户:

在准备安装环境时,我还以为 京东云 轻量应用服务器 VPS 掉线了。看下面截图:、

Apt 源都是清华,都是运行同样的命令:

sudo apt update && sudo apt upgrade -y

这台是 北京-腾讯云 4Mbps 带宽 VPS: 2C2G50GB

这台是 北京-京东云 带宽 5Mbps, VPS: 2C4G60GB

看看腾讯在小日本儿-京东 VPS:2C2G50GB 网络 30Mbps

下面这个 VPS 在美国,1C1G10GB 网络 50Mbps,不到 $13/yr 含一个公网IP

再看看从国外源的下载速度:

腾讯-北京云:

京东-北京云:

这就是我为什么开工单,要 “京东” 调整, 说好的 5Mbps 带宽,到了国际出口就 100.8Kbps ,只有 1/50 性能

开个工单:

运行商信息:

供应商 配置 带宽 每月-流量 费用
京东-北京云 2C4G60GB 5Mbps 双向 500GB 36个月:498/原价2459.16
腾讯-北京云 2C2G50GB 4Mbps 单向 1024GB 12个月:99元
腾讯-日本京东云 2C2G50GB 30Mbps 单向 300GB 12个月:99元
美国加州 1C1G10GB 50Mbps 双向 512GB 12个月:不到 95元

注:C=CPU's core,G=内存,GB=硬盘

安装 Claude Code

参考:Set up Claude Code - Anthropic  
           https://docs.anthropic.com/en/docs/claude-code/setup

1 确保 Ubuntu 24 是最新的系统

sudo apt update && sudo apt upgrade -y

2 安装 Node.js 18以上的版本 与 npm 

sudo apt remove nodejs npm
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

校验 Node.js / npm 安装的版本:

node --version # Should show v20.x.x
npm --version  # Should show 10.x.x or higher

root@usw:~# sudo apt remove nodejs npm
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'nodejs' is not installed, so not removed
Package 'npm' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  linux-image-6.8.0-35-generic linux-modules-6.8.0-35-generic linux-modules-extra-6.8.0-35-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2025-06-23 07:50:58 - Installing pre-requisites
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Get:2 https://pkgs.tailscale.com/stable/ubuntu noble InRelease                                      
Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu noble InRelease [256 kB]                         
Hit:4 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:5 http://nova.clouds.archive.ubuntu.com/ubuntu noble-backports InRelease
Fetched 262 kB in 2s (170 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apt-transport-https is already the newest version (2.8.3).
ca-certificates is already the newest version (20240203).
curl is already the newest version (8.5.0-2ubuntu10.6).
The following packages were automatically installed and are no longer required:
  linux-image-6.8.0-35-generic linux-modules-6.8.0-35-generic linux-modules-extra-6.8.0-35-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  dirmngr gnupg-utils gpg-agent gpgsm keyboxd libksba8 pinentry-curses
Suggested packages:
  pinentry-gnome3 tor parcimonie xloadimage gpg-wks-server scdaemon pinentry-doc
Recommended packages:
  gnupg-l10n gpg-wks-client
The following NEW packages will be installed:
  dirmngr gnupg gnupg-utils gpg-agent gpgsm keyboxd libksba8 pinentry-curses
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 1485 kB of archives.
After this operation, 3411 kB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 libksba8 amd64 1.6.6-1build1 [122 kB]
Get:2 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 dirmngr amd64 2.4.4-2ubuntu17.2 [323 kB]
Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 gnupg-utils amd64 2.4.4-2ubuntu17.2 [109 kB]
Get:4 http://nova.clouds.archive.ubuntu.com/ubuntu noble/main amd64 pinentry-curses amd64 1.2.1-3ubuntu5 [35.2 kB]
Get:5 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 gpg-agent amd64 2.4.4-2ubuntu17.2 [227 kB]
Get:6 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 gpgsm amd64 2.4.4-2ubuntu17.2 [232 kB]
Get:7 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 keyboxd amd64 2.4.4-2ubuntu17.2 [78.3 kB]
Get:8 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates/main amd64 gnupg all 2.4.4-2ubuntu17.2 [359 kB]
Fetched 1485 kB in 0s (4153 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libksba8:amd64.
(Reading database ... 55112 files and directories currently installed.)
Preparing to unpack .../0-libksba8_1.6.6-1build1_amd64.deb ...
Unpacking libksba8:amd64 (1.6.6-1build1) ...
Selecting previously unselected package dirmngr.
Preparing to unpack .../1-dirmngr_2.4.4-2ubuntu17.2_amd64.deb ...
Unpacking dirmngr (2.4.4-2ubuntu17.2) ...
Selecting previously unselected package gnupg-utils.
Preparing to unpack .../2-gnupg-utils_2.4.4-2ubuntu17.2_amd64.deb ...
Unpacking gnupg-utils (2.4.4-2ubuntu17.2) ...
Selecting previously unselected package pinentry-curses.
Preparing to unpack .../3-pinentry-curses_1.2.1-3ubuntu5_amd64.deb ...
Unpacking pinentry-curses (1.2.1-3ubuntu5) ...
Selecting previously unselected package gpg-agent.
Preparing to unpack .../4-gpg-agent_2.4.4-2ubuntu17.2_amd64.deb ...
Unpacking gpg-agent (2.4.4-2ubuntu17.2) ...
Selecting previously unselected package gpgsm.
Preparing to unpack .../5-gpgsm_2.4.4-2ubuntu17.2_amd64.deb ...
Unpacking gpgsm (2.4.4-2ubuntu17.2) ...
Selecting previously unselected package keyboxd.
Preparing to unpack .../6-keyboxd_2.4.4-2ubuntu17.2_amd64.deb ...
Unpacking keyboxd (2.4.4-2ubuntu17.2) ...
Selecting previously unselected package gnupg.
Preparing to unpack .../7-gnupg_2.4.4-2ubuntu17.2_all.deb ...
Unpacking gnupg (2.4.4-2ubuntu17.2) ...
Setting up libksba8:amd64 (1.6.6-1build1) ...
Setting up pinentry-curses (1.2.1-3ubuntu5) ...
Setting up gpg-agent (2.4.4-2ubuntu17.2) ...
Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent.socket → /usr/lib/systemd/user/gpg-agent.socket.
Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-ssh.socket → /usr/lib/systemd/user/gpg-agent-ssh.socket.
Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-extra.socket → /usr/lib/systemd/user/gpg-agent-extra.socket.
Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-browser.socket → /usr/lib/systemd/user/gpg-agent-browser.socket.
Setting up gpgsm (2.4.4-2ubuntu17.2) ...
Setting up dirmngr (2.4.4-2ubuntu17.2) ...
Created symlink /etc/systemd/user/sockets.target.wants/dirmngr.socket → /usr/lib/systemd/user/dirmngr.socket.
Setting up keyboxd (2.4.4-2ubuntu17.2) ...
Created symlink /etc/systemd/user/sockets.target.wants/keyboxd.socket → /usr/lib/systemd/user/keyboxd.socket.
Setting up gnupg-utils (2.4.4-2ubuntu17.2) ...
Setting up gnupg (2.4.4-2ubuntu17.2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.4) ...
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Get:2 https://deb.nodesource.com/node_20.x nodistro InRelease [12.1 kB]                                                                                              
Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu noble InRelease [256 kB]                                                                                          
Get:4 https://pkgs.tailscale.com/stable/ubuntu noble InRelease                       
Get:5 https://deb.nodesource.com/node_20.x nodistro/main amd64 Packages [11.5 kB]    
Hit:6 http://nova.clouds.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:7 http://nova.clouds.archive.ubuntu.com/ubuntu noble-backports InRelease
Fetched 286 kB in 2s (176 kB/s)
Reading package lists... Done
2025-06-23 07:51:13 - Repository configured successfully.
2025-06-23 07:51:13 - To install Node.js, run: apt-get install nodejs -y
2025-06-23 07:51:13 - You can use N|solid Runtime as a node.js alternative
2025-06-23 07:51:13 - To install N|solid Runtime, run: apt-get install nsolid -y 

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-image-6.8.0-35-generic linux-modules-6.8.0-35-generic linux-modules-extra-6.8.0-35-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 32.0 MB of archives.
After this operation, 199 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_20.x nodistro/main amd64 nodejs amd64 20.19.2-1nodesource1 [32.0 MB]
Fetched 32.0 MB in 5s (6893 kB/s) 
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package nodejs.
(Reading database ... 55243 files and directories currently installed.)
Preparing to unpack .../nodejs_20.19.2-1nodesource1_amd64.deb ...
Unpacking nodejs (20.19.2-1nodesource1) ...
Setting up nodejs (20.19.2-1nodesource1) ...
root@usw:~# 
root@usw:~# 
root@usw:~# 
root@usw:~# node --version # Should show v20.x.x
npm --version  # Should show 10.x.x or higher
v20.19.2
10.8.2
root@usw:~# 

3 配置 npm

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global

添加路径:

echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

添加依赖包(可选)

sudo apt install -y git ripgrep

4 安装 CC

npm install -g @anthropic-ai/claude-code

root@usw:~# mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
root@usw:~# echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
root@usw:~# sudo apt install -y git ripgrep
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
git is already the newest version (1:2.43.0-1ubuntu7.2).
The following packages were automatically installed and are no longer required:
  linux-image-6.8.0-35-generic linux-modules-6.8.0-35-generic linux-modules-extra-6.8.0-35-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  ripgrep
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1551 kB of archives.
After this operation, 5335 kB of additional disk space will be used.
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu noble/universe amd64 ripgrep amd64 14.1.0-1 [1551 kB]
Fetched 1551 kB in 0s (3722 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package ripgrep.
(Reading database ... 60606 files and directories currently installed.)
Preparing to unpack .../ripgrep_14.1.0-1_amd64.deb ...
Unpacking ripgrep (14.1.0-1) ...
Setting up ripgrep (14.1.0-1) ...
root@usw:~# npm install -g @anthropic-ai/claude-code

added 3 packages in 12s

2 packages are looking for funding
  run `npm fund` for details

5 启动 CC

创建项目文件夹

mkdir ~/projects

复制项目到文件夹

root@usw:~/projects# ll
total 12
drwxr-xr-x  3 root root 4096 Jun 23 08:22 ./
drwx------ 12 root root 4096 Jun 23 08:25 ../
drwxr-xr-x  6 root root 4096 Jun 23 08:23 48.removebg/
root@usw:~/projects# 

进入项目的文件夹中,运行 claude

root@usw:~/projects# cd 48.removebg/
root@usw:~/projects/48.removebg# claude 

claude 

第一次运行 CC

1 配置显示风格

柔光用 1,我最后选的 3 为了看清楚些。

2 订阅用户登录或使用 API 付费

打折时付了年度会员,用的 1,如下:

用浏览器打开上面的链接,会拿到验证码:

粘贴到屏幕提示区

成功后,如图:

下一页,安全须知

3 进入项目

总结:

在没有 GUI 的环境里 Claude Code 是一个玩美的终端上使用 AI 的方案。如果你也是 Claude 订阅用户 ( Claude Pro ),你的 $20/月的 Claude Pro 订阅本身就包含了在终端使用 Claude Code 的权限,并且会提供比免费用户更多的使用量。 

如上图中,Anthropic 也提供另一种方式:API 令牌使用费来使用 CC,这种按量付费模式独立于你的 $20 订阅,对于需要更高使用量、灵活或特定需求的用户。

以上是在加州服务器运行,如果你的终端在国内,就要使用工具。

在国内安装 CC

使用本地代理安装 Claude Code

npm config set proxy http://127.0.0.1:1081
npm config set https-proxy http://127.0.0.1:1081
npm install -g @anthropic-ai/claude-code

注: socket port 1081 根据你自己的实际情况修改

最后把 npm anthropic 有关域加到路由,如: (以前有篇文章 用 DELETED tunel 组网)

{
  "type": "field",
  "domain": [
    "registry.npmjs.org",
    "*.npmjs.org",
    "npmjs.com",
    "*.npmjs.com",
    "anthropic.com",
    "*.anthropic.com",
    "console.anthropic.com",
    "api.anthropic.com",
    "claude.ai",
    "*.claude.ai"
  ],
  "outboundTag": "usw_outbound"
}

修改后要重启应用

下面是日志反映出主机路由的变化,BJN:

USW:

这样在北京的主机上就可以使用 CC 来维护代码


网站公告

今日签到

点亮在社区的每一天
去签到