Articles » SSH guide

How to SSH Into a Vast.ai GPU Instance

SSH is the most reliable way to install packages, move code, inspect logs, and manage long-running jobs on a rented GPU.

Create a dedicated key

ssh-keygen -t ed25519 -C "vast-gpu" -f ~/.ssh/vast_gpu

Upload only vast_gpu.pub to your Vast.ai account. Never upload or share the private key.

Connect to the instance

Choose an SSH-enabled template. After the instance starts, copy the connection command shown by Vast. The platform often maps container port 22 to a different public port, so use the displayed value:

ssh -i ~/.ssh/vast_gpu -p MAPPED_PORT root@HOST_ADDRESS

Verify the current host fingerprint before accepting it, especially when an address may have been reused.

Confirm GPU and disk access

nvidia-smi
pwd
df -h

If nvidia-smi fails, fix GPU access before installing more software. Check free disk space before downloading model weights.

Copy project files

scp -i ~/.ssh/vast_gpu -P MAPPED_PORT train.py root@HOST_ADDRESS:/workspace/

For repeated transfers, use rsync with the same SSH key and port so unchanged files are skipped.

Forward a private service

ssh -i ~/.ssh/vast_gpu -p MAPPED_PORT -L 8888:127.0.0.1:8888 root@HOST_ADDRESS

Open http://127.0.0.1:8888 locally. Tunneling is safer than publishing an unauthenticated notebook or development API.

Common failures

Consult the official Vast.ai quickstart for the current console workflow. Next, learn how to preserve data between sessions.