npm install or pip install is checked before it runs.
For a single developer machine, use the per-user setup in the Quickstart. For a macOS, Linux, or Windows fleet, deploy through your MDM. For a Kubernetes workload, use the Kubernetes guide. Per-user and system-wide installs can coexist.
Requirements
- Linux or Windows. Run as root on Linux, or as an administrator on Windows. Windows requires Windows 10 or 11. The release is x86-64, with ARM64 using emulation.
- PMG in a system path. On Linux, use a root-owned path such as
/usr/local/bin, executable by all users. On Windows, the binary must be%ProgramFiles%\safedep\pmg\pmg.exe. A user-local binary is rejected.
What gets created
System install uses PATH shims only. It does not create the
~/.pmg.rc alias layer that per-user setup installs on macOS and Linux.Windows machines
-
Download and extract
pmg_Windows_x86_64.zipfrom a v0.29.0 or later release. Earlier versions do not support Windows system install. -
Open PowerShell as administrator in the extracted directory, then install:
-
Open a new terminal as your normal user and verify:
npm should resolve under %ProgramFiles%\safedep\pmg\bin, and PMG must block the test package. System install puts shims ahead of machine-wide Node.js installations. A per-user install cannot do that.
System install sets the required ownership and permissions. Run it before editing the managed config as administrator. See the system-install reference for permission requirements and troubleshooting.
For fleets, the Windows MDM scripts perform these steps and deploy your config. For shell and interception limits, see Windows coverage.
Docker images
PMG must be installed inside the image: PMG on the Docker host cannot see installs that run duringdocker build.
The easiest path is to copy the PMG binary from the published PMG container image into your application image.
Compared to a Linux VM, a Dockerfile needs two adjustments:
- No
sudo.RUNsteps execute as root. If your base image switches to a non-rootUSER, addUSER rootbefore the install step and switch back after. - Set
PATHwithENV.RUNsteps do not source/etc/profile.d, so add the shim directory toPATHexplicitly.
RUN npm install or RUN pip install after the ENV PATH line now goes through PMG, and the running container inherits the protection, for any USER. Derived images inherit it too.
If your build environment cannot pull from GHCR, install PMG with
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh before running pmg setup install --system.Linux VMs
-
Place PMG in a system path.
Not installed yet? The install script places it in
/usr/local/bin, prompting for sudo for the copy:Already installed in a user location? Copy it over:PMG rejects a binary in a user location (~/.local/bin,~/go/bin), since any single user could modify it. The install script also picks~/.local/binwhen that is on yourPATH. If it did, use the copy command above. -
Install system-wide:
-
Activate the PATH. The install writes
/etc/profile.d/pmg.sh, which prepends the shim directory for login shells. New login sessions pick it up. For an already-open shell:
Verify
On Linux, run in a VM shell or inside a container (docker run --rm -it <image> sh):
Configuration
The system config file is authoritative for every user. PMG ignores a per-userconfig.yml while the managed config is active: /etc/safedep/pmg/config.yml on Linux or %PROGRAMDATA%\safedep\pmg\config.yml on Windows.
pmg config set and pmg config edit are disabled under a system config. Edit the file as root on Linux or as an administrator on Windows, or redeploy it through your image or configuration management.
On Linux, runtime data (event logs, cloud-sync state, cache) stays per user under
~/.config/safedep/pmg and ~/.cache/safedep/pmg. The invoking user must be able to write their own config directory. Relocate it with PMG_CONFIG_DIR / PMG_CACHE_DIR if needed.%APPDATA%\safedep\pmg. Event logs, cache, and runtime data are under %LOCALAPPDATA%\safedep\pmg.
Cloud sync
Cloud sync reports install events to your SafeDep Cloud tenant, where they appear in Package Guard. To set it up, enable cloud sync and provide your tenant ID and API key from SafeDep Cloud through theSAFEDEP_API_KEY and SAFEDEP_TENANT_ID environment variables.
In a Docker image
Enable sync and set a stable endpoint name before your install steps. Use this setting for containers that run outside Kubernetes.PMG_CLOUD_ENDPOINT_ID every run registers as a new endpoint. A stable name is what you will recognize in Endpoint Hub.
The credentials exist only where you run docker, as shell exports or CI secrets. They never go in the Dockerfile.
In the running container, pass them through at start:
environment: entries and Kubernetes Secret references work the same way. If the container is short-lived, a CI job for example, run pmg cloud sync before it exits so buffered events are not destroyed with it.
For reproducible builds, pin PMG to a release tag from the published PMG container image.
docker build, install steps need no credentials: PMG buffers each event locally. Deliver the buffer in one final RUN step, with the credentials mounted as BuildKit secrets. Mount them directly as environment variables so PMG can use its standard SAFEDEP_API_KEY and SAFEDEP_TENANT_ID credential resolver:
--secret reads the variable exported where you run the build:
A blocked package fails its
RUN step: later steps never run, including the final sync, so a failed build uploads nothing. The block itself shows in the build output.Complete Dockerfile with cloud sync
Complete Dockerfile with cloud sync
On a shared VM
On Linux, enable sync in/etc/safedep/pmg/config.yml as root:
/etc/profile.d/safedep-cloud.sh, so every login shell exports them:
On Windows
As administrator, setcloud.enabled: true in %PROGRAMDATA%\safedep\pmg\config.yml. Each user can then run these commands in their own session:
Certificates
System install does not set up a MITM certificate authority. For npm and pip on Linux, PMG’s default ephemeral CA and environment-variable injection are sufficient. To install a persistent CA into the OS trust store, runpmg setup cert install --system as your normal user.
PATH shims protect the commands that go through them. To route every process on a Linux host through PMG, including processes that never read PATH or proxy variables, see Kernel Enforcement on Linux. It needs the same command as root: sudo pmg setup cert install --system.
Uninstall
On Windows, run from an administrator terminal:sudo rm /usr/local/bin/pmg, or uninstall it through your package manager if you installed it that way.
Troubleshooting
Try runningpmg setup doctor first. The cases below apply to Linux. For Windows, see Windows coverage.
npm or pip resolves outside the shim directory
npm or pip resolves outside the shim directory
Version managers like nvm, pyenv, volta, and asdf prepend their own bin directories from rc files that run after
/etc/profile.d, putting the real npm/pip ahead of the shims.- Keep
/usr/local/lib/pmg/binfirst in a durableENV PATHor login PATH - Or call
pmg npm/pmg pipdirectly
pip inside a virtualenv bypasses PMG
pip inside a virtualenv bypasses PMG
After
source .venv/bin/activate, bare pip uses the venv binary and skips the shims. Call pmg pip inside the venv.Every pmg command fails with permission denied on the event log
Every pmg command fails with permission denied on the event log
Another account created or owns your config directory. Check the path in the error message.If the path is inside your own home, a root run created it as root. This happens with If the path is inside another user’s home, your environment leaked that user’s
su without - (prefer sudo or su -) and with images that set ENV HOME before dropping root. Restore ownership:HOME or XDG_CONFIG_HOME (common with sudo -u on CI runners). Fix the environment. Do not chown another user’s directory, that breaks PMG for them.System Install Reference
Full reference in the PMG repo: binary validation rules, user data directories, and limitations.
PMG
How PMG blocks malicious packages at install time.

