Ubuntu 22.04 安装 Apache Caldera 指南

Ubuntu 22.04 从零安装 Apache Caldera 5.3.0 对抗模拟平台:apt 依赖、Node.js 18 工具链、源码获取、Python 依赖安装、启动验证、systemd 托管与卸载清理,含排障实录。

Apache CalderaCaldera2026/10/14

Ubuntu 22.04 安装 Apache Caldera 指南

目标:在 Ubuntu 22.04 服务器上从零安装并运行 Apache Caldera 5.3.0 对抗模拟(红队)平台,覆盖基础环境、源码部署、前端构建、启动验证、systemd 托管与卸载。本文所有命令与回显均在一台 Ubuntu 22.04.5 LTS 服务器上实测通过。

一、环境信息

本指南实测环境如下:

项目值
操作系统Ubuntu 22.04.5 LTS(x86_64)
Python3.10.12(系统自带,pip 22.0.2)
Node.jsv18.20.8(npm 10.8.2,nodesource 源安装)
Caldera 版本5.3.0(源码 git tag,commit b24f6e7)
部署目录/opt/caldera
Web 服务端口8888(HTTP/REST API/WebUI)
Agent 通讯端口7010(TCP)、7011(UDP)、7012(WebSocket)、8022(SSH 隧道)、2222(FTP)、8853(DNS)
内存/CPU 建议官方推荐 8GB+ 内存、2+ CPU

💡 说明:Caldera(MITRE 贡献、2025 年进入 Apache 孵化器)是一套自动化对抗模拟/红队平台,通过「agent(代理)+ operation(行动)」模型在受控环境内模拟攻击者行为,用于评估与训练防御能力。Ubuntu 22.04 自带 Python 3.10,满足 v5 的 Python 3.9+ 要求,部署路径比 CentOS 8 更短。

二、前置条件

2.1 硬件与网络

  • 内存 8GB 以上、CPU 2 核以上(官方推荐基线);
  • 可访问外网(GitHub、PyPI、nodesource);
  • 放行 8888 端口供 WebUI/API 使用;如需 agent 回连,放行 7010、7012 等通讯端口。

2.2 更新 apt 软件源

apt-get update

回显(节选):

Get:18 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [35.6 kB]
Fetched 49.0 MB in 7s (7258 kB/s)
Reading package lists…

三、版本选型说明

Caldera 官方源码仓库(github.com/apache/caldera)以 git tag 管理版本:

git ls-remote --tags https://github.com/apache/caldera.git

回显(节选,较新 tag):

9ceb72d7bd11a3c8dc3851c90d0899379ab250d1        refs/tags/5.0.0
cc4b9cdb31996f78027cee288d1b285e5335c9d2        refs/tags/5.1.0
06e4ded7bf4949a17a1437b7e25586f48e99564d        refs/tags/5.2.0
dd22d543a519afe63ca35c454bf1add5d75c45dc        refs/tags/5.3.0
版本代说明
2.x / 3.x早期版本,旧式模板 UI
4.x4.0 起重构 API 层
5.x5.0 起前端改为 VueJS(magma 插件),需 Node.js 16+ 构建

解读:v5 是当前主线,5.3.0 为实测最新稳定 tag,本指南按此版本部署。v5 的 UI 与 agent 通讯栈与旧版差异较大,从旧版升级需整体迁移。

四、在线源码安装方案(官方推荐)

本章按「编译依赖 → Node.js → 源码 → Python 依赖 → 配置 → 启动 → 验证 → systemd 托管」的完整 0→1 顺序执行。

4.1 安装编译依赖

Caldera 需要 gcc 与 Python 开发头文件以编译部分依赖,同时需要 git 拉取源码:

DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev git gcc g++ make wget curl

回显(节选):

Updating certificates in /etc/ssl/certs…
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d…
done.

确认 Python 版本:

python3 --version
pip3 --version

回显:

Python 3.10.12
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

💡 说明:Ubuntu 22.04 自带 Python 3.10.12,满足 Caldera 5.x 的 Python 3.9+ 要求,无需额外安装 Python(对比 CentOS 8 需另装 python39,见《CentOS 8 安装 Apache Caldera 指南》篇)。

4.2 安装 Node.js 18(前端构建依赖)

v5 的 VueJS 前端首次启动时通过 --build 构建,需要 Node.js 16+。Ubuntu 22.04 官方源自带的 nodejs 为 v12(过老),直接安装后启动会报 FileNotFoundError: [Errno 2] No such file or directory: 'npm'(详见 7.2 节),因此使用 nodesource 官方源安装 Node.js 18:

curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
node --version
npm --version

回显:

v18.20.8
10.8.2

💡 技术拓展:Node.js 版本选型不止 18 一条线——

版本线生命周期适用场景
18(LTS)已进维护期兼容性好,本文实测采用
20(LTS)活跃维护新部署可选用
22(LTS)当前活跃长期项目推荐
非 LTS(如 21/23)短命仅尝鲜,不用于生产

本文采用 18 线(Caldera README 建议 Node.js 16+,18 充分满足且生态兼容性最好)。

4.3 获取官方源码

官方推荐 --recursive --tag 完整克隆(plugins 全部是 git 子模块,magma 插件含 VueJS 前端源码,缺失会导致启动失败):

cd /opt
git clone https://github.com/apache/caldera.git --recursive --tag 5.3.0

回显(节选):

Cloning into 'caldera'…
…
Submodule path 'plugins/ssl': checked out '1ae843111919b5a6e58a03917bd9be6b852ecb1f'
Submodule path 'plugins/stockpile': checked out '08f37d8c1c5325910176d9fbaf9a83efccafd96c'
Submodule path 'plugins/training': checked out 'd4d19a2f1f829d5fea904a44e52a8ba5d7e07696'

确认版本:

cd /opt/caldera
git log -1 --format="%H %s"

回显:

b24f6e7a99cab19cbf417009bda9b9c6c81abc31 app version tag

4.4 安装 Python 依赖

cd /opt/caldera
python3 -m pip install -r requirements.txt

回显(节选,末尾):

Successfully installed Markdown-3.4.4 … aiohttp-3.10.11 aiohttp-apispec-3.0.0b2 … cryptography-44.0.1 … jinja2-3.1.6 ldap3-2.9.1 lxml-4.9.4 marshmallow-3.20.1 … pyyaml-6.0.1 reportlab-4.0.4 … websockets-15.0 yarl-1.22.0 …

验证核心依赖可导入:

python3 -c "import aiohttp, cryptography, websockets; print('deps OK')"

回显:

deps OK

4.5 修改默认配置(账号与密钥)

默认配置文件为 /opt/caldera/conf/default.yml。首次部署必须修改默认管理员口令与 API 密钥:

grep -A 6 "^users:" /opt/caldera/conf/default.yml

回显:

users:
  blue:
    blue: admin
  red:
    admin: admin
    red: admin

将 red 组管理账号 admin 的默认口令由 admin 改为统一示例口令 q1w2e3r4(首次登录后应再修改为强口令):

sed -i "s|^    admin: admin$|    admin: q1w2e3r4|" /opt/caldera/conf/default.yml
grep -A 5 "^users:" /opt/caldera/conf/default.yml

回显:

users:
  blue:
    blue: admin
  red:
    admin: q1w2e3r4
    red: admin

⚠️ 注意:Caldera 自带 red/blue 两组,默认口令均为 admin。生产环境还应同步修改 api_key_red、api_key_blue、encryption_key 与 crypt_salt(各参数含义与改法见《Apache Caldera 配置参数详解》篇)。

4.6 启动服务并验证

首次启动使用 --insecure(等价 -E default)加 --build 构建 VueJS 前端:

cd /opt/caldera
nohup python3 server.py --insecure --build > /tmp/caldera.log 2>&1 &

启动日志(节选,前端构建约需 1–2 分钟):

WARNING  --insecure flag set. Caldera will use server.py:219
         the default user accounts in default.yml config file.
INFO     Using main config from                server.py:228
         conf/default.yml
INFO     Building VueJS front-end.             server.py:265
…
INFO     VueJS front-end build complete.       server.py:268
INFO     Enabled plugin: fieldmanual           app_svc.py:131
INFO     Enabled plugin: manx                  app_svc.py:131
INFO     Enabled plugin: stockpile             app_svc.py:131
INFO     Enabled plugin: sandcat               app_svc.py:131
…
INFO     Enabled plugin: magma                 app_svc.py:131
INFO     Creating SSH listener on 0.0.0.0, …
INFO     serving on 0.0.0.0:2222               server.py:741

验证一:端口监听:

ss -ltnp | grep -E "8888|7010|7012"

回显:

LISTEN 0      128          0.0.0.0:8888      0.0.0.0:*    users:(("python3",pid=5263,fd=42))
LISTEN 0      100          0.0.0.0:7010      0.0.0.0:*    users:(("python3",pid=5263,fd=37))

验证二:Web 页面:

curl -s -o /dev/null -w "HTTP %{http_code}\n" http://127.0.0.1:8888/
curl -s http://127.0.0.1:8888/ | grep -oE "<title>[^<]*</title>"

回显:

HTTP 200
<title>Magma | Caldera</title>

验证三:REST API 健康检查(API 密钥头 KEY: ADMIN123,即 default.yml 的 api_key_red 默认值):

curl -s http://127.0.0.1:8888/api/v2/health -H "KEY: ADMIN123"

回显(节选):

{"application": "Caldera", "version": "5.3.0", "access": "RED", "plugins": [{"name": "access", "description": "A toolkit containing initial access throwing modules", "enabled": true, …}]}

验证四:WebUI 登录。登录端点为 POST /enter,表单(form)格式提交,成功返回 302 并下发 API_SESSION 会话 Cookie:

curl -s -v -X POST http://127.0.0.1:8888/enter -d "username=admin&password=q1w2e3r4" 2>&1 | grep -iE "HTTP/1.1|Set-Cookie"

回显:

< HTTP/1.1 302 Found
< Location: /
< Set-Cookie: API_SESSION="gAAAAABqzm3MP4g5ZkizMPFLbPmEGc1ITSxiJrGuhGivkKarlGFzI0AA1YIIWj5OmAlOKTwidLRrxMq8P_m_ykiYLk1TcWpauDzUBUXIoHY6pn5hi9NufAfTALI6gmC5AGJPHHOOWm69x7nXBzzvEEKnfEnldcNzgiWGAzvLKYAhyW5fwqJWEgQ="; HttpOnly; Path=/

⚠️ 注意:登录接口接收表单格式(username=admin&password=q1w2e3r4),用 JSON 体提交会登录失败——实测踩坑点。

至此,Caldera 已在 Ubuntu 22.04 上完整运行。

4.7 systemd 托管

⚠️ 前置要求:systemd 托管需要 Linux 真机(systemd 环境),Ubuntu 22.04 服务器均满足;若在受限模拟环境无法复现 systemctl,属宿主能力限制,不影响真实服务器上的可用性。

创建服务单元 /etc/systemd/system/caldera.service:

cat > /etc/systemd/system/caldera.service <<'EOF'
[Unit]
Description=Apache Caldera
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/caldera
ExecStart=/usr/bin/python3 /opt/caldera/server.py
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

加载并启动(每个单元单独一行操作):

systemctl daemon-reload
systemctl enable caldera.service
systemctl start caldera.service
systemctl status caldera.service

预期回显(节选):

● caldera.service - Apache Caldera
     Loaded: loaded (/etc/systemd/system/caldera.service; enabled; vendor preset: enabled)
     Active: active (running) …

⚠️ 注意:生产环境请勿同时使用 nohup 后台启动与 systemd 托管;systemd 托管的 ExecStart 不带 --insecure,安全参数在配置文件中显式设置(详见《Apache Caldera 配置参数详解》篇)。

五、方案对比与选择建议

维度官方源码安装(本文方案)离线/内网部署
版本5.3.0(git tag 精确锁定)需提前下载源码包与依赖 wheel
是否需联网需要(GitHub、PyPI、npm)不需要
前端构建首次启动 --build需在离线环境预构建
优点官方推荐、升级方便断网隔离环境可用
缺点依赖外网可达依赖预下载工作量

解读:可联网环境直接采用本文方案;内网隔离环境需先在一台可联网机器上 git clone --recursive、pip download -r requirements.txt 后整体搬运。Ubuntu 22.04 因自带 Python 3.10,比 CentOS 8 少了「另装 Python」环节,安装路径更短。

六、配置说明

  • 配置文件位置:/opt/caldera/conf/default.yml,启动时可用 -E <文件名> 指定其他环境文件。
  • 常用键速览(完整详解见《Apache Caldera 配置参数详解》篇):
键默认值作用
port8888Web/API 监听端口
host0.0.0.0监听地址
api_key_redADMIN123红队 API 密钥(HTTP 头 KEY:)
api_key_blueBLUEADMIN123蓝队 API 密钥
encryption_keyADMIN123加密密钥(生产必改)
crypt_saltREPLACE_WITH_RANDOM_VALUE加密盐(生产必改)
pluginsaccess…magma 共 15 个启用的插件列表
usersred/blue 两组用户账号与口令
  • 数据目录:/opt/caldera/data;exfil 外传数据目录默认 /tmp/caldera(键 exfil_dir)。

七、常见问题(FAQ)

Q1:启动报 FileNotFoundError: [Errno 2] No such file or directory: 'npm'

实测排障过程:直接启动 python3 server.py --insecure --build 时,前端构建子进程找不到 npm:

File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(...)
FileNotFoundError: [Errno 2] No such file or directory: 'npm'

定位:Ubuntu 22.04 官方源 nodejs 为 v12 且不附带 npm;Caldera v5 前端构建要求 Node.js 16+。解决:按 4.2 节用 nodesource 源安装 Node.js 18 后重新启动:

node --version

回显:

v18.20.8

Q2:启动报 ModuleNotFoundError: No module named 'plugins.manx.app'

根因:克隆源码时未带 --recursive,plugins 子模块未拉取。解决:

cd /opt/caldera
git submodule update --init --recursive

并用 --build 重新启动,日志确认出现 Enabled plugin: magma 与 VueJS front-end build complete.。

Q3:启动日志出现 go/upx 版本警告

WARNING  go does not meet the minimum version of 1.19
WARNING  upx does not meet the minimum version of 0.0.0.

go(1.19+)用于按需编译 Go 系 agent(sandcat)、upx 用于压缩 payload,均为可选依赖,不影响核心框架运行。

Q4:登录返回 302 但 WebUI 仍跳回登录页?

登录接口只接受表单格式(-d "username=admin&password=q1w2e3r4"),若用 JSON 体提交(-d '{"username":"admin","password":"q1w2e3r4"}')无法解析,服务器不会下发 API_SESSION Cookie,导致「看似登录成功实则未登录」。用 curl -v 观察响应头是否有 Set-Cookie: API_SESSION 即可判断。

Q5:如何确认服务已停止?

ss -ltn | grep 8888

无输出即 8888 已关闭;或用 ps -ef | grep "[s]erver.py" 查看进程。

八、卸载与清理

停止服务:

systemctl stop caldera.service
systemctl disable caldera.service
rm -f /etc/systemd/system/caldera.service

卸载 Python 依赖并删除部署目录(先卸载依赖再删目录):

cd /opt/caldera
python3 -m pip uninstall -y -r requirements.txt
cd /opt
rm -rf /opt/caldera

💡 说明:Caldera 无系统级安装包,卸载即「停进程 + 删目录 + 卸载 pip 依赖」三步;systemd 单元为管理员自建,一并删除即可,无残留。

九、参考链接