To remotely SSH into a Vast.ai instance, you'll need to follow a series of steps to ensure a secure and successful connection. Vast.ai is a platform that offers affordable GPU cloud computing resources, and connecting via SSH allows you to manage your rented instances directly from your local machine. Here's how you can do it:
1. Rent and Deploy an Instance on Vast.ai
Before you can SSH into an instance, you need to rent one:
- Log in to Vast.ai: Visit Vast.ai and log in to your account. If you don't have one, you'll need to create an account.
- Browse Instances: Click on "Rent GPU/CPU" to browse available instances.
- Configure Your Instance:
- Select Resources: Choose the GPU, CPU, memory, and storage that meet your needs.
- Choose Image: Select an operating system or pre-configured environment (e.g., Ubuntu 20.04, with or without pre-installed software).
- Set SSH Key: During configuration, ensure you add your SSH public key (more on this below).
- Deploy: Once configured, click on "Deploy" to start your instance.
2. Set Up an SSH Key Pair
SSH keys are a secure way to log into your instance without using passwords.
- Generate an SSH Key Pair (if you don't already have one):
- Add Your Public Key to Vast.ai:
- Copy Public Key: Open your public key file (
~/.ssh/id_rsa.pub) and copy its contents.
cat ~/.ssh/id_rsa.pub
- Add to Vast.ai:
- Go back to Vast.ai.
- In the deployment configuration, find the section for SSH Keys.
- Paste your public key into the SSH key field.
3. Obtain Connection Details
After your instance is running:
- Go to Your Instances:
- Click on "Instances" in the Vast.ai dashboard.
- View Instance Details:
- Find your running instance.
- Click on the "Connect" button or the SSH icon next to your instance.
- Note Connection Info:
- IP Address: The public IP address of your instance.
- Port: The SSH port (usually
22, but sometimes a different port like 2022 or 2200).
- Username: Default is often
root unless specified otherwise.
4. Connect to Your Instance via SSH
On Linux/macOS
Example:
ssh -i ~/.ssh/id_rsa -p 2200 root@123.45.67.89
- Accept the Host Key:
- On first connection, you'll be prompted to confirm the authenticity of the host. Type
yes and press Enter.
On Windows
- Using PuTTY:
- Download PuTTY and PuTTYgen if you haven't already.
- Convert Your Private Key:
- Open PuTTYgen.
- Click "Load" and select your private key file.
- Save the key in PuTTY format.
- Configure Connection:
- Open PuTTY.
- Host Name: Enter
[USERNAME]@[HOST_IP].
- Port: Enter
[PORT].
- Connection Type: Ensure SSH is selected.
- Specify the Private Key:
- In PuTTY, go to Connection > SSH > Auth.
- Browse and select your private key file.
- Connect:
- Click "Open" to start the SSH session.
- Accept the host key if prompted.
5. Troubleshooting Connection Issues
- Permission Denied (Publickey):
- Ensure your SSH public key is correctly added to the instance.
- Verify that you're using the correct private key to connect.
- Connection Timed Out:
- Check that the instance is running and not in a stopped state.
- Ensure that there are no network issues blocking the connection.
- Incorrect Port:
- Double-check the SSH port provided by Vast.ai; it may not be the default port
22.
- Firewall Settings:
- If you're behind a firewall, ensure that outbound connections to the SSH port are allowed.
6. Using SSH Agent (Optional but Recommended)
An SSH agent can manage your keys and simplify the connection process.
7. Accessing the Instance via Web Terminal (Alternative Method)
If you're unable to connect via SSH:
- Use Vast.ai's Web-Based Console:
- In the Instances section, click on the Web Console icon next to your instance.
- This will open a browser-based terminal session.
- Limitations:
- The web console may have limited functionality compared to an SSH session.
- It's useful for quick tasks or troubleshooting SSH connection issues.
8. Securing Your SSH Connection
For enhanced security:
- Use Strong Passphrases: Protect your private key with a strong passphrase.
- Keep Your Keys Secure: Never share your private key. Store it securely on your local machine.
- Regularly Update SSH Keys: Consider regenerating your SSH keys periodically.
By following these steps, you should be able to establish a secure SSH connection to your Vast.ai instance. This allows you to interact with the instance's operating system, run commands, and manage files as if you were accessing a local machine.
If you encounter any issues, Vast.ai's documentation and support forums are valuable resources. Additionally, ensure that your local network doesn't have restrictions on SSH connections, especially if you're connecting from a corporate or educational network.
Happy computing on Vast.ai!