VMware CentOS 7 上的完整部署Pentagi
PentAGI 在 VMware CentOS 7 上的完整部署实战:从网络踩坑到正常访问
1. 写在前面
PentAGI 是一个基于大语言模型的自动化渗透测试平台,项目地址:
https://github.com/vxcontrol/pentagi
它可以在 Docker 沙箱中执行渗透测试,支持多种 LLM Provider,并提供 Web UI、REST/GraphQL API、报告导出等能力。
本文整合了安装配置指南和实际踩坑记录,按完整部署流程整理,适合同样使用 VMware + CentOS 7 环境的人参考。
2. 环境说明
本文基于以下环境:
- Windows 宿主机
- VMware Workstation
- CentOS 7 虚拟机
- VMware NAT 网络模式
- 虚拟机 IP:
192.168.137.136 - VMware NAT 网关:
192.168.137.2 - Docker CE
- Docker Compose v2.21.0
- PentAGI Installer v2.0.0-87ac00f
- PentAGI 最终版本:2.1.0-879e87c
如果你的 IP、网卡名、镜像源或防火墙配置不同,请按实际环境调整。
3. 系统要求
PentAGI 官方最低要求:
- Docker 和 Docker Compose
- 2 vCPU
- 4GB 内存
- 20GB 可用磁盘
- 可访问互联网
实际建议:
- 4 vCPU
- 8GB 或更多内存
- 独立测试网络环境
- 已获得授权或自有测试目标
4. 总体部署流程
- 准备 VMware 虚拟机
- 配置 CentOS 网络
- 安装 Docker 和 Docker Compose
- 配置 Docker 镜像源
- 下载 PentAGI 部署文件
- 配置
.env - 预拉取 Docker 镜像
- 启动 PentAGI
- 访问 Web UI
- 创建第一个 Flow
5. 准备 VMware 虚拟机
在 VMware 中关闭虚拟机后,编辑虚拟机设置:
- 内存:至少 4096 MB
- 处理器:至少 2 核,建议 4 核
- 网络适配器:NAT
- 网络适配器:勾选 Connected
在 Windows 宿主机查看 VMware 虚拟网卡:
ipconfig
常见 VMware NAT 网段:
VMware Network Adapter VMnet8: 192.168.137.1
这里有一个关键区别:
192.168.137.1是宿主机上的 VMware 虚拟网卡地址192.168.137.2才是 VMware NAT 网关地址
虚拟机默认网关必须配置为 192.168.137.2。
6. 配置 CentOS 网络
6.1 检查当前网络
ip addr show
ip route
cat /etc/resolv.conf
重点检查三项:
- 网卡是否 UP
- 网卡是否拿到 IP
- 是否有默认路由
常见异常现象:
ping -c 3 114.114.114.114
connect: Network is unreachable
这说明虚拟机没有可用网络路由。
检查网卡:
ip link show
如果看到:
2: ens33: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT
说明网卡处于 DOWN 状态。
6.2 推荐静态 IP 配置
编辑网卡配置文件:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
写入以下内容:
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=ens33
DEVICE=ens33
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=192.168.137.136
NETMASK=255.255.255.0
GATEWAY=192.168.137.2
DNS1=223.5.5.5
DNS2=119.29.29.29
如果使用 DHCP:
BOOTPROTO=dhcp
GATEWAY=192.168.137.2
DNS1=223.5.5.5
DNS2=119.29.29.29
6.3 固定使用 network.service
为避免 NetworkManager 与 network.service 冲突,建议:
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl enable network
清掉旧配置后重启:
ip addr flush dev ens33
ip route flush dev ens33
systemctl restart network
6.4 验证网络
ip addr show ens33
ip route
ping -c 3 223.5.5.5
nslookup docker.io
正常结果:
192.168.137.136/24
default via 192.168.137.2 dev ens33
7. 安装 Docker 和 Docker Compose
7.1 安装基础工具
yum install -y yum-utils wget unzip
7.2 添加 Docker 官方源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
7.3 安装 Docker
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
7.4 启动 Docker
systemctl enable --now docker
验证:
docker --version
docker compose version
如果需要普通用户使用 Docker:
usermod -aG docker $USER
newgrp docker
注意:加入 docker 组等同于授予 root 权限,只在可信环境使用。
8. 配置 Docker 镜像源
Docker Hub 在部分网络环境下无法直接访问,建议先配置镜像源。
8.1 写入镜像源
cat > /etc/docker/daemon.json <<'EOF'
{
"registry-mirrors": [
"https://docker.1ms.run"
]
}
EOF
备选镜像源:
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
8.2 重启 Docker
systemctl restart docker
8.3 验证镜像源
docker info | grep -A5 "Registry Mirrors"
docker pull hello-world
9. 下载 PentAGI 部署文件
官方提供了安装器,但在 Docker Hub 访问受限的环境中,安装器会因为网络检查不通过而卡住。
建议直接使用手动部署方式。
9.1 创建目录
mkdir -p /opt/pentagi
cd /opt/pentagi
9.2 下载配置和 Compose 文件
curl -o .env https://raw.githubusercontent.com/vxcontrol/pentagi/master/.env.example
curl -o docker-compose.yml https://raw.githubusercontent.com/vxcontrol/pentagi/master/docker-compose.yml
9.3 创建挂载用空配置
touch example.custom.provider.yml
touch example.ollama.provider.yml
10. 配置 .env
vi /opt/pentagi/.env
10.1 配置 LLM Provider
至少需要配置一个语言模型 Provider。
DeepSeek:
DEEPSEEK_API_KEY=你的DeepSeek密钥
OpenAI:
OPEN_AI_KEY=你的OpenAI密钥
本地 Ollama:
OLLAMA_SERVER_URL=http://localhost:11434
OLLAMA_SERVER_MODEL=你的模型名
其他可选 Provider:
ANTHROPIC_API_KEY=
GEMINI_API_KEY=
GLM_API_KEY=
KIMI_API_KEY=
QWEN_API_KEY=
10.2 配置外部访问
默认只允许本机访问。如果需要从 Windows 宿主机或其他电脑访问:
PENTAGI_LISTEN_IP=0.0.0.0
PUBLIC_URL=https://虚拟机IP:8443
CORS_ORIGINS= https://localhost:8443 ,https://虚拟机IP:8443
示例:
PENTAGI_LISTEN_IP=0.0.0.0
PUBLIC_URL=https://192.168.137.136:8443
CORS_ORIGINS= https://localhost:8443 ,https://192.168.137.136:8443
10.3 修改安全配置
首次部署建议修改:
COOKIE_SIGNING_SALT=随机字符串
PENTAGI_POSTGRES_USER=postgres
PENTAGI_POSTGRES_PASSWORD=强密码
LOCAL_SCRAPER_USERNAME=自定义用户名
LOCAL_SCRAPER_PASSWORD=自定义密码
10.4 可选配置
代理:
PROXY_URL=http://代理IP:端口
搜索引擎:
DUCKDUCKGO_ENABLED=true
SPLOITUS_ENABLED=true
TAVILY_API_KEY=
PERPLEXITY_API_KEY=
11. 预拉取 Docker 镜像
如果 Compose 拉取镜像超时,可以先手动从镜像源拉取并打标签。
11.1 拉取镜像
docker pull docker.1ms.run/vxcontrol/pentagi:latest
docker pull docker.1ms.run/vxcontrol/pgvector:latest
docker pull docker.1ms.run/vxcontrol/scraper:latest
11.2 打标签
docker tag docker.1ms.run/vxcontrol/pentagi:latest vxcontrol/pentagi:latest
docker tag docker.1ms.run/vxcontrol/pgvector:latest vxcontrol/pgvector:latest
docker tag docker.1ms.run/vxcontrol/scraper:latest vxcontrol/scraper:latest
12. 启动 PentAGI
12.1 检查配置
cd /opt/pentagi
docker compose config
12.2 启动服务
docker compose up -d
12.3 查看状态
docker compose ps
正常状态:
Container pentagi Started
Container pgvector Healthy
Container scraper Started
Container pgexporter Started
查看日志:
docker compose logs -f
13. 访问 PentAGI
13.1 访问地址
CentOS 虚拟机本机访问:
https://127.0.0.1:8443
Windows 宿主机访问:
https://192.168.137.136:8443
注意:不要在 Windows 浏览器访问 https://127.0.0.1:8443,那访问的是 Windows 宿主机自己。
13.2 默认账号
admin@pentagi.com
admin
首次登录后立即修改默认密码。
13.3 浏览器要求
PentAGI 前端要求:
- Firefox 104 或更高版本
- Chrome 97 或更高版本
- Edge 97 或更高版本
如果 Firefox 版本太旧,页面会报:
(intermediate value)().findLast is not a function
解决办法:
- 升级 Firefox
- 或使用 Windows 宿主机上的新版 Edge/Chrome
13.4 自签名证书
PentAGI 默认使用自签名证书,浏览器第一次访问会提示:
Potential Security Risk Ahead
本地测试环境选择:
Advanced -> Accept the Risk and Continue
公网部署应替换为正式 SSL 证书。
14. 首次使用
登录后进入 Flows:
- 点击 New Flow
- 选择 Automation 或 Assistant
- 选择 LLM Provider
- 填写测试目标、范围和期望结果
- 提交后监控执行过程
示例任务:
Assess https://target.example for common web application vulnerabilities.
Focus on authentication, file handling, and injection issues.
Stay within the provided target only and summarize confirmed findings.
15. 踩坑记录汇总
15.1 CentOS 虚拟机没有网络
现象:
connect: Network is unreachable
原因:ens33 DOWN,或没有默认路由。
处理:
ip link set ens33 up
dhclient ens33
ip route replace default via 192.168.137.2 dev ens33
关键:VMware NAT 网关是 192.168.137.2,不是 192.168.137.1。
15.2 network.service 启动失败
现象:
Job for network.service failed because the control process exited with error code.
日志:
RTNETLINK answers: File exists
原因:ifcfg-ens33 存在重复配置,NetworkManager 与 network.service 冲突。
处理:
重写干净的静态配置,并停用 NetworkManager:
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl enable network
15.3 安装器网络检查不通过
现象:
- DNS resolution failed for docker.io
- Cannot reach external services via HTTPS
- Cannot pull Docker images from registry
原因:安装器强制检查 Docker Hub 连通性,但当前网络无法直接访问 Docker Hub。
处理:跳过安装器,使用手动部署。
15.4 daemon.json 写坏
现象:
invalid character 's' looking for beginning of value
原因:手动编辑时删掉了 JSON 开头。
处理:
cat > /etc/docker/daemon.json <<'EOF'
{
"registry-mirrors": [
"https://docker.1ms.run"
]
}
EOF
systemctl reset-failed docker
systemctl restart docker
15.5 镜像源白名单限制
现象:
this image is not in the allowlist.
原因:部分镜像源只代理白名单仓库。
处理:换用 docker.1ms.run,或手动拉取后重新打标签。
15.6 容器正常但 UI 打不开
现象:
ss -tlnp | grep 8443
显示:
127.0.0.1:8443
原因:Compose 只把端口映射到了虚拟机本机。
处理:
PENTAGI_LISTEN_IP=0.0.0.0
重建容器:
docker compose down
docker compose up -d
确认:
0.0.0.0:8443
16. 常用验证命令
网络:
ip addr show ens33
ip route
ping -c 3 223.5.5.5
DNS:
nslookup docker.io
nslookup github.com
Docker:
docker info
docker compose ps
docker compose logs pentagi --tail=100
端口:
ss -tlnp | grep 8443
17. 经验总结
网络排查顺序
遇到 Network is unreachable:
- 检查网卡是否 UP
- 检查网卡是否拿到 IP
- 检查是否有默认路由
- 检查默认网关是否正确
- 检查 DNS 是否可用
Docker 排查顺序
- 确认
daemon.json是合法 JSON - 确认 Docker 能识别 Registry Mirrors
- 先测试
docker pull hello-world - 再测试项目实际需要的镜像
- 不同镜像源白名单和稳定性不同,逐个验证
安装器不一定必须成功
PentAGI 安装器会强制检查 Docker Hub 连通性。Docker Hub 访问受限时,可以直接使用 .env.example 和 docker-compose.yml 手动部署。
18. 安全提醒
PentAGI 是渗透测试平台,只允许用于:
- 自己拥有权限的系统
- 已获得明确授权的目标
- 隔离测试环境或 CTF 场景
禁止对未授权系统执行扫描、探测或攻击操作。
浙公网安备 33010602011771号