How to connect to RunPod via SSH
Quick answer
To connect to a RunPod instance via
SSH, first obtain your pod's public IP and SSH key from the RunPod dashboard. Then use ssh -i path/to/key.pem user@pod-ip in your terminal to establish a secure connection.PREREQUISITES
Python 3.8+RunPod account with active podSSH client installed (e.g., OpenSSH)Access to RunPod dashboardSSH private key file downloaded from RunPod
Setup
Before connecting via SSH, ensure you have an active RunPod instance running. Download your pod's SSH private key from the RunPod dashboard. Confirm your local machine has an SSH client installed (OpenSSH is standard on Linux/macOS; Windows users can use Windows Terminal or PuTTY).
pip install runpod output
$ pip install runpod Collecting runpod Downloading runpod-1.0.0-py3-none-any.whl (10 kB) Installing collected packages: runpod Successfully installed runpod-1.0.0
Step by step
Use the following steps to connect to your RunPod instance via SSH:
- Locate your pod's public IP address and SSH key file from the RunPod dashboard.
- Open your terminal or command prompt.
- Run the
sshcommand with the private key and pod IP.
import os
# Replace with your actual key path and pod IP
ssh_key_path = os.path.expanduser('~/.ssh/runpod_key.pem')
pod_ip = '123.45.67.89'
# SSH command to connect
ssh_command = f"ssh -i {ssh_key_path} ubuntu@{pod_ip}"
print("Run this command in your terminal to connect:")
print(ssh_command) output
Run this command in your terminal to connect: ssh -i /home/user/.ssh/runpod_key.pem ubuntu@123.45.67.89
Common variations
If your pod uses a different username (e.g., root or ec2-user), replace ubuntu accordingly. For Windows users without native SSH, use PuTTY with the private key converted to .ppk format. You can also automate SSH connections using Python's subprocess module or paramiko library.
import subprocess
import os
ssh_key_path = os.path.expanduser('~/.ssh/runpod_key.pem')
pod_ip = '123.45.67.89'
username = 'ubuntu'
# Run SSH command from Python
subprocess.run(['ssh', '-i', ssh_key_path, f'{username}@{pod_ip}']) output
Connecting to 123.45.67.89... Welcome to your RunPod instance!
Troubleshooting
- Permission denied: Ensure your private key file has correct permissions (
chmod 600 key.pem). - Connection timed out: Verify your pod is running and the IP address is correct.
- SSH client not found: Install OpenSSH or use an alternative SSH client.
Key Takeaways
- Always download and securely store your RunPod SSH private key before connecting.
- Use the correct username and IP address from the RunPod dashboard for SSH access.
- Set proper file permissions on your SSH key to avoid permission errors.
- Windows users may need PuTTY and key conversion for SSH access.
- Automate SSH connections with Python subprocess or paramiko for advanced workflows.