Skip to main content

How To Connect to a Pod Instance through VSCode

This tutorial explains how to connect directly to your Pod instance through VSCode, allowing you to work within your volume directory as if the files were stored on your local machine. By following this guide, you will learn to create a Pod instance and establish a connection from the Pod to your VSCode editor.

When you're finished, you'll be able to seamlessly develop and manage files on your Pod instance using VSCode.

Prerequisites

To complete this tutorial, you will need:

  • A local development environment with VSCode installed. Download it from Visual Studio Code.
  • Familiarity with basic command-line operations and SSH.
  • Your SSH key setup with RunPod, see Use SSH.
  • A RunPod account. Sign up at RunPod.
  • (Optional) A GitHub account for code management.

Create a Pod instance

In this step, you will create a Pod instance.

  1. Navigate to Pods and select + Deploy.
  2. Choose between GPU and CPU based on your requirements.
  3. Customize your instance by setting up the following:
    1. (Optional) Specify a Network volume.
    2. Select an instance type. For example, A40.
    3. (Optional) Provide a template. For example, RunPod Pytorch.
    4. (GPU only) Specify your compute count.
  4. Review your configuration and select Deploy On-Demand.

For more information, see Manage Pods.

Next, establish a connection with your Pod.

Establish a connection

In this step, you will connect to your Pod instance using SSH.

  1. From the Pods page, select the Pod you just deployed.

  2. Select Connect and copy the SSH over exposed TCP: (Supports SCP & SFTP) command. For example:

    ssh root@123.456.789.80 -p 12345 -i ~/.ssh/id_ed12345

Next, you will set up the connection in VSCode.

Configuring VSCode for remote development

To connect your VSCode editor to the Pod instance, follow these steps:

  1. Open VSCode and install the Dev Container extension.

  2. Open the Command Palette (CTRL+SHIFT+P) and choose Remote-SSH: Add New SSH Host.

  3. Enter the copied SSH command from the previous step and paste it into the text box.

  4. Update your .ssh/config file by saving the configuration. For example:

    Host your_pod_instance
    HostName 123.456.789.80
    User root
    Port 12345
    IdentityFile ~/.ssh/id_ed12345
  5. In the Command Palette, select Remote-SSH: Connect to Host and choose your newly added host.

You are now connected to your Pod instance within VSCode and can work on your volume directory as if it were local.