| name | vastai-security-basics |
| description | Apply Vast.ai security best practices for API keys and instance access.
Use when securing API keys, hardening SSH access to GPU instances,
or auditing Vast.ai security configuration.
Trigger with phrases like "vastai security", "vastai secrets",
"secure vastai", "vastai API key security", "vastai ssh security".
|
| allowed-tools | Read, Write, Grep |
| version | 1.11.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","vast-ai","api","security"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Vast.ai Security Basics
Overview
Security best practices for Vast.ai API keys, SSH access to GPU instances, data protection on rented hardware, and credential management. Vast.ai instances run as root on shared hardware, requiring careful attention to data lifecycle.
Prerequisites
- Vast.ai account with API key
- Understanding of SSH key management
- Secrets manager available (optional but recommended)
Instructions
Step 1: API Key Management
echo '.vast_api_key' >> .gitignore
echo '.env' >> .gitignore
export VASTAI_API_KEY="$(vault kv get -field=api_key secret/vastai)"
import os
def get_api_key():
key = os.environ.get("VASTAI_API_KEY")
if not key:
key_file = os.path.expanduser("~/.vast_api_key")
if os.path.exists(key_file):
key = open(key_file).read().strip()
if not key:
raise ValueError("VASTAI_API_KEY not set and ~/.vast_api_key not found")
return key
Step 2: SSH Key Security
ssh-keygen -t ed25519 -f ~/.ssh/vastai_key -C "vastai-instances" -N ""
ssh -i ~/.ssh/vastai_key -p PORT root@HOST