Systemd 加固辅助程序 - 由 strace 分析导引的自动系统d 服务加固
Automatic systemd service hardening guided by strace profiling.
SHH can generate an optimal set of hardening options for each of your services, so you can raise the security level of your system without sweating about random errors in production caused by too restrictive sandboxing.
Official repository - Mirror repository
Strace needs to be installed and its executable reachable in PATH. Strace version >= 6.6 is currently required.
You need a Rust build environment for example from rustup.
Run in the current repository:
cargo build --release
install -Dm 755 -t /usr/local/bin target/release/shhcrates.iosudo cargo install --root /usr/local systemd-hardening-helperSee GitHub releases for Debian packages built for each tagged version.
Arch Linux users can install the shh AUR package.
Nixos/Nix users can install the latest package from the unstable branch.
To harden a system unit named SERVICE.service:
shh service start-profile SERVICE. The service will be restarted with strace profiling.shh service finish-profile SERVICE -a. The service will be restarted with a hardened configuration built from previous runtime profiling, to allow it to run safely as was observed during the profiling period, and to deny other dangerous system actions.Run shh -h for full command line reference, or append -h to a subcommand to get help.
[!WARNING] The hardening options generated by
shhare by construction not portable across different systems. They depend on many factors, and may break the service if any of those change:
- the code path covered during profiling
- the Linux kernel version
- the libc used
- the systemd version
Reusing options generated by
shhon a system with a different environment (ie. different Linux distribution) is very likely to break the service.
If you want to run a quick test to see what options would be generated, you can use shh run -- COMMAND.
Current directory and PATH environment variable both influence the program execution, reset those first:
$ cd /
export PATH=/usr/local/bin:/usr/bin:/binThen to see what options would be generated for a curl https://www.example.com invocation:
…Or to sandbox as much as possible:
…暂无开放 Issues,或尚未同步最近议题。