LightYear
/Docs
DocsSecuritySecurity Best Practices for GPU Servers

Security Best Practices for GPU Servers

A comprehensive security checklist for GPU servers running ML workloads.

intermediate
9 min read
LightYear Team
Updated April 24, 2026
securitygpuhardeningbest-practices
Ready to get started?

Overview

GPU servers running ML workloads have unique security considerations: large datasets, model weights, and API keys are high-value targets.

Network Security

Firewall Rules

Restrict access to the minimum required ports:

SSH (22 or custom) → Your IP only Jupyter (8888) → Your IP only All other ports → Blocked

Use SSH Tunnelling for Jupyter

Instead of exposing port 8888:

>_BASH
$ssh -L 8888:localhost:8888 root@<SERVER_IP>

VPN for Multi-Server Clusters

Use WireGuard or Tailscale for inter-node communication:

>_BASH
$apt-get install -y wireguard

Credential Management

Never Hardcode API Keys

PYTHON
# ❌ Bad
openai.api_key = "sk-abc123..."

# ✅ Good
import os
openai.api_key = os.environ["OPENAI_API_KEY"]

Use Environment Files

>_BASH
$# .env (never commit to git)
$OPENAI_API_KEY=sk-abc123...
$HF_TOKEN=hf_abc123...
>_BASH
$# .gitignore
$.env
$*.key
$secrets/

Data Security

Encrypt Sensitive Datasets

>_BASH
$# Encrypt with GPG
$gpg --symmetric --cipher-algo AES256 sensitive_data.csv
$
$# Decrypt
$gpg --decrypt sensitive_data.csv.gpg > sensitive_data.csv

Secure Model Weights

If your model weights are proprietary:

  1. Store in private object storage with access keys
  2. Download at runtime, not baked into Docker images
  3. Delete from disk after use if not needed persistently

Monitoring

Audit Login Attempts

>_BASH
$# Recent successful logins
$last -n 20
$
$# Failed login attempts
$grep "Failed password" /var/log/auth.log | tail -20
$
$# Currently logged-in users
$who

Monitor GPU Usage

>_BASH
$# Detect unexpected GPU processes
$nvidia-smi --query-compute-apps=pid,used_memory,name --format=csv

Security Checklist

  • SSH key authentication only (no passwords)
  • Firewall restricts all ports except SSH
  • Jupyter accessed via SSH tunnel only
  • API keys in environment variables, not code
  • .env files in .gitignore
  • fail2ban installed
  • System packages updated weekly
  • Snapshots taken before major changes

Was this article helpful?

Your cookie choices for this website

This site uses cookies and related technologies, as described in our privacy policy, for purposes that may include site operation, analytics, and enhanced user experience. You may choose to consent to our use of these technologies, or manage your own preferences. Cookie policy