这篇文章上次修改于 397 天前,可能其部分内容已经发生变化,如有疑问可询问作者。 ### 使用GitHub项目一键安装及更新脚本: ### Auto install link (Do NOT run script as root, it will prompt for sudo) ```shell wget https://raw.githubusercontent.com/itiligent/Easy-OpenVAS-Installer/main/openvas-install.sh && chmod +x openvas-install.sh && ./openvas-install.sh ``` ### Auto upgrade link ```shell wget https://raw.githubusercontent.com/itiligent/Easy-OpenVAS-Installer/main/openvas-upgrade.sh && chmod +x openvas-upgrade.sh && ./openvas-upgrade.sh ``` ### 记录: ```shell #一些前置配置: sudo usermod -aG sudo yc export ALL_PROXY="socks5h://192.168.0.35:10808" export all_proxy="$ALL_PROXY" ``` #### 1. 安装结尾报错: ```shell bash: line 1: /usr/local/bin/greenbone-feed-sync: No such file or directory Job for openvasd.service failed because the control process exited with error code. See "systemctl status openvasd.service" and "journalctl -xeu openvasd.service" for details. ``` 因为/usr/local/bin/greenbone-feed-sync文件不存在导致服务器无法启动,需要使用pipx安装。 ```shell sudo apt update sudo apt install -y pipx sudo pipx install --global greenbone-feed-sync ls -l /usr/local/bin/greenbone-feed-sync sudo -u gvm /usr/local/bin/greenbone-feed-sync --help ``` 成功后再同步并启动服务: ```shell sudo /usr/local/bin/greenbone-feed-sync -vv sudo systemctl restart openvasd ospd-openvas gvmd gsad sudo systemctl --no-pager --full status openvasd ospd-openvas gvmd gsad ``` 如果 `pipx install --global` 提示已存在,执行: ```shell sudo pipx uninstall --global greenbone-feed-sync sudo pipx install --global greenbone-feed-sync ``` #### 2. /usr/local/bin/openvasd不存在 > 原因: > > /usr/local/bin/openvasd` 根本不存在。安装脚本创建了 systemd 服务,却没有成功把 Rust 编译出的 `openvasd` 二进制复制过去;脚本没有在 `cargo build` 或 `cp` 失败时退出,且随后删除了源码目录。 重新下载并编译 `openvasd`。下面会自动取当前最新 `openvas-scanner` release,与该安装脚本的做法一致: 注意:编译期间可能会因为代理问题无法build,启用终端代理,必要时转换socks5为http。 ```shell privoxy配置: forward-socks5 / 192.168.0.35:10808 . listen-address 0.0.0.0:1080 终端配置: export http_proxy=http://127.0.0.1:1080 export https_proxy=http://127.0.0.1:1080 ``` 开始请求GitHub最新release: ```shell VERSION=$(curl -fsSL https://api.github.com/repos/greenbone/openvas-scanner/releases/latest | sed -n 's/.*"tag_name": "v\{0,1\}\([^"]*\)".*/\1/p') echo "$VERSION" mkdir -p ~/source ~/build curl -fL "https://github.com/greenbone/openvas-scanner/archive/refs/tags/v${VERSION}.tar.gz" -o ~/source/openvas-scanner.tar.gz tar -C ~/source -xzf ~/source/openvas-scanner.tar.gz source "$HOME/.cargo/env" cd "$HOME/source/openvas-scanner-${VERSION}/rust/src/openvasd" cargo build --release cd "$HOME/source/openvas-scanner-${VERSION}/rust/src/scannerctl" cargo build --release sudo install -o root -g root -m 0755 ../../target/release/openvasd /usr/local/bin/openvasd sudo install -o root -g root -m 0755 ../../target/release/scannerctl /usr/local/bin/scannerctl ``` 确认二进制已存在: ```shell ls -l /usr/local/bin/openvasd /usr/local/bin/scannerctl /usr/local/bin/openvasd --help ``` 再启动服务: ```shell sudo systemctl enable openvasd sudo systemctl reset-failed openvasd sudo systemctl restart openvasd ospd-openvas gvmd gsad sudo systemctl --no-pager --full status openvasd ospd-openvas gvmd gsad ``` 如果磁盘占用比较高,可先停用: 先停止依赖服务,再停 PostgreSQL: ```shell sudo systemctl stop gsad gvmd ospd-openvas openvasd sudo systemctl stop postgresql ``` 避免 `openvasd` 持续自动重试占用资源: ```shell sudo systemctl disable --now openvasd ``` #### 3. 编译失败: Rust 的 Kerberos 绑定找不到 OpenVAS C 库的头文件和静态库 `openvas-scanner 23.50.24` 的 Rust 构建会用 Docker 或 Podman 构建并导出静态 C 库,不能仅靠系统已安装的开发包完成。 `make` 未完成,因此 `build-cache/archives/include` 没有生成。 安装 Podman 后重试。注意此步骤会下载构建镜像、占用较多 CPU、磁盘和网络,建议继续保持 PostgreSQL 停止: ```shell sudo apt update sudo apt install -y podman podman info cd ~/source/openvas-scanner-23.50.24/rust ###期间的apt安装时需要取消代理。 make cargo build --release ``` ```shell #`make` 成功时应显示类似: Using container runtime: podman ``` 并生成: ```shell crates/nasl-c-lib/build-cache/archives/include ``` 完成后再安装二进制: ```shell sudo install -o root -g root -m 0755 target/release/openvasd /usr/local/bin/openvasd sudo install -o root -g root -m 0755 target/release/scannerctl /usr/local/bin/scannerctl ``` 编译成功。两个 Git 警告是因为源码来自 release tarball,不含 `.git` 目录,只影响版本元数据,不影响 `openvasd` 功能。 安装生成的二进制: ```shell cd ~/source/openvas-scanner-23.50.24/rust sudo install -o root -g root -m 0755 target/release/openvasd /usr/local/bin/openvasd sudo install -o root -g root -m 0755 target/release/scannerctl /usr/local/bin/scannerctl /usr/local/bin/openvasd --help ``` 然后恢复服务: ```shell sudo systemctl start postgresql sudo systemctl enable openvasd sudo systemctl reset-failed openvasd sudo systemctl restart openvasd ospd-openvas gvmd gsad sudo systemctl --no-pager --full status openvasd ospd-openvas gvmd gsad ``` 四个服务均显示 `active (running)` 即完成。
没有评论