Server Agent - Linux & macOS
Install the ByteHide Server Agent on Linux or macOS for zero-code runtime protection of all .NET applications. Install once, and every .NET 6+ process on the machine is automatically protected.
Requirements
- Linux (x64, ARM64, Alpine) or macOS (x64, Apple Silicon)
- .NET 6+ runtime installed (for the apps you want to protect)
curlorwgetsudoaccess (for writing to/opt/and/etc/)- A ByteHide account with a Monitor project (create one here)
- Your ByteHide Project Token from app.bytehide.com
Option 1: Shell Script (Recommended)
No .NET SDK required. Downloads a self-contained binary from GitHub.
curl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | bash -s -- --token bh_xxxxxxxxxxxxcurl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | bash -s -- --token bh_xxxxxxxxxxxxThis single command:
- Detects your OS and architecture automatically
- Downloads the correct binary from GitHub Releases
- Extracts agent DLLs to the install directory
- Configures environment variables system-wide
- Installs
bytehide-agentto/usr/local/bin/
Script Options
| Option | Default | Description |
|---|---|---|
--token, -t | (required) | Your ByteHide API token |
--version | 1.0.5 | Agent version to install |
--install-dir | /usr/local/bin | Where to place the CLI binary |
--no-install | false | Only download binary, don't run install |
Private Hosting
If you host the binary on a private server:
BYTEHIDE_AGENT_URL=https://your-server.com/bytehide-agent-1.0.5-linux-x64.tar.gz \
curl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | bash -s -- --token bh_xxxxxxxxxxxxBYTEHIDE_AGENT_URL=https://your-server.com/bytehide-agent-1.0.5-linux-x64.tar.gz \
curl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | bash -s -- --token bh_xxxxxxxxxxxxOption 2: dotnet tool
Requires the .NET SDK installed on the server.
# Install the CLI tool
dotnet tool install -g Bytehide.Monitor.AgentCli
# Run the agent installer
bytehide-agent install --token bh_xxxxxxxxxxxx# Install the CLI tool
dotnet tool install -g Bytehide.Monitor.AgentCli
# Run the agent installer
bytehide-agent install --token bh_xxxxxxxxxxxxIf using a private NuGet feed:
dotnet nuget add source "https://pkgs.dev.azure.com/bytehide/Monitor/_packaging/bytehide-monitor-enterprise/nuget/v3/index.json" \
--name bytehide --username bytehide --password "YOUR_PAT" --store-password-in-clear-text
dotnet tool install -g Bytehide.Monitor.AgentCli --version 1.0.5
bytehide-agent install --token bh_xxxxxxxxxxxxdotnet nuget add source "https://pkgs.dev.azure.com/bytehide/Monitor/_packaging/bytehide-monitor-enterprise/nuget/v3/index.json" \
--name bytehide --username bytehide --password "YOUR_PAT" --store-password-in-clear-text
dotnet tool install -g Bytehide.Monitor.AgentCli --version 1.0.5
bytehide-agent install --token bh_xxxxxxxxxxxxWhat Gets Installed
Linux
| Item | Path |
|---|---|
| Agent DLLs | /opt/bytehide/agent/ |
| CLI binary | /usr/local/bin/bytehide-agent |
| Configuration | /opt/bytehide/agent/monitor.config.json |
| Logs | /opt/bytehide/agent/logs/ |
macOS
| Item | Path |
|---|---|
| Agent DLLs | /usr/local/share/bytehide/agent/ |
| CLI binary | /usr/local/bin/bytehide-agent |
| Configuration | /usr/local/share/bytehide/agent/monitor.config.json |
| Logs | /usr/local/share/bytehide/agent/logs/ |
Environment Variables
The installer configures environment variables in multiple locations to cover all scenarios:
Linux:
| File | Purpose |
|---|---|
/etc/profile.d/bytehide-agent.sh | Interactive shell sessions (SSH, bash) |
/etc/environment.d/bytehide-agent.conf | systemd services |
/etc/environment | Universal fallback |
macOS:
| File | Purpose |
|---|---|
/etc/zshenv | All zsh sessions (default shell on macOS) |
launchctl setenv | Immediate effect in current session |
Variables Set
| Variable | Value (Linux) |
|---|---|
DOTNET_STARTUP_HOOKS | /opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dll |
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES | Bytehide.Monitor.ServerAgent |
BYTEHIDE_MONITOR_TOKEN | Your token |
BYTEHIDE_MONITOR_CONFIG | /opt/bytehide/agent/monitor.config.json |
Verify Installation
bytehide-agent statusbytehide-agent statusExpected output:
Installed: Yes
Install path: /opt/bytehide/agent
Agent files: 7 DLLs
Environment Variables:
DOTNET_STARTUP_HOOKS = /opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dll
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES = Bytehide.Monitor.ServerAgent
BYTEHIDE_MONITOR_TOKEN = bh_xxx...xxxx
Protection: Active — all new .NET processes are protected Installed: Yes
Install path: /opt/bytehide/agent
Agent files: 7 DLLs
Environment Variables:
DOTNET_STARTUP_HOOKS = /opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dll
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES = Bytehide.Monitor.ServerAgent
BYTEHIDE_MONITOR_TOKEN = bh_xxx...xxxx
Protection: Active — all new .NET processes are protectedRestart Required
After installing the agent, you must restart any running .NET applications for protection to take effect. Existing processes do not pick up environment variable changes automatically.
Platform-Specific Notes
systemd Services
For .NET apps running as systemd services, the agent environment is loaded automatically from /etc/environment.d/bytehide-agent.conf. No changes to your service files needed.
If you want to set variables per-service instead of system-wide:
[Service]
Environment=DOTNET_STARTUP_HOOKS=/opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dll
Environment=ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Bytehide.Monitor.ServerAgent
Environment=BYTEHIDE_MONITOR_TOKEN=bh_xxxxxxxxxxxx[Service]
Environment=DOTNET_STARTUP_HOOKS=/opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dll
Environment=ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Bytehide.Monitor.ServerAgent
Environment=BYTEHIDE_MONITOR_TOKEN=bh_xxxxxxxxxxxxAlpine Linux (musl)
The installer automatically detects Alpine/musl and downloads the linux-musl-x64 binary. No extra configuration needed.
SSH Sessions
After installing, new SSH sessions automatically pick up the environment variables from /etc/profile.d/bytehide-agent.sh. For the current session:
source /etc/profile.d/bytehide-agent.shsource /etc/profile.d/bytehide-agent.shSupported Platforms
| Platform | Architecture | RID |
|---|---|---|
| Linux (glibc) | x64 | linux-x64 |
| Linux (glibc) | ARM64 | linux-arm64 |
| Linux (musl/Alpine) | x64 | linux-musl-x64 |
| macOS | Intel | osx-x64 |
| macOS | Apple Silicon | osx-arm64 |
Troubleshooting
Agent not loading
Check that environment variables are set:
Bashecho $DOTNET_STARTUP_HOOKSecho $DOTNET_STARTUP_HOOKSIf empty, source the profile:
Bashsource /etc/profile.d/bytehide-agent.shsource /etc/profile.d/bytehide-agent.shVerify the DLL exists:
Bashls -la /opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dllls -la /opt/bytehide/agent/Bytehide.Monitor.ServerAgent.dllMake sure you restarted the application after installing the agent.
Permission errors
Run with sudo:
curl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | sudo bash -s -- --token bh_xxxxxxxxxxxxcurl -sSL https://raw.githubusercontent.com/bytehide/monitor-dotnet-agent/main/install.sh | sudo bash -s -- --token bh_xxxxxxxxxxxxsystemd service not picking up variables
Reload systemd after install:
sudo systemctl daemon-reload
sudo systemctl restart your-app.servicesudo systemctl daemon-reload
sudo systemctl restart your-app.serviceNext Steps
- Agent CLI Reference - Manage the agent (status, config, logs, uninstall)
- JSON Configuration - Customize protection rules
- Docker Installation - Install in Docker containers