Step-by-step guide to using SSH in VS Code

Greg Foster
Greg Foster
Graphite software engineer
Try Graphite

If you work on remote servers, cloud instances, or headless development environments, SSH access is essential. VS Code's Remote SSH extension lets you open folders and files from a remote machine directly in your local editor, with full support for IntelliSense, debugging, terminal access, and more. This eliminates the need for clunky file transfers or remote-desktop setups. For developers using tools like Graphite to manage stacked pull requests, integrating SSH access in VS Code streamlines the entire remote development and version control workflow.

  • A local machine with VS Code installed
  • An SSH client (built-in on macOS/Linux; install OpenSSH on Windows)
  • A remote system running an SSH server (e.g., Linux VM, cloud server, Raspberry Pi)
  1. Open VS Code
  2. Go to the Extensions tab (sidebar)
  3. Search for "Remote - SSH"
  4. Install the Remote - SSH extension by Microsoft
  5. Reload VS Code if prompted

This enables VS Code Remote SSH support and allows you to open folders on remote machines as if they were local.

In a terminal window, test your SSH connection:

Terminal
ssh user@remote-host

If you connect without errors, you're good to go. If not, double-check your hostname, username, and SSH key permissions.

Create or update your SSH config file at ~/.ssh/config:

Terminal
Host dev-server
HostName 192.0.2.10
User ubuntu
IdentityFile ~/.ssh/id_ed25519

This simplifies your commands. Instead of typing the full SSH command, you can use:

Terminal
ssh dev-server

VS Code will also detect these named hosts for use in the Remote SSH connection interface.

  1. Open the Command Palette (F1 or Ctrl+Shift+P)
  2. Type and select Remote-SSH: Connect to Host...
  3. Choose your host (e.g., dev-server)
  4. VS Code will install the vscode-server on the remote host and connect

You'll know you're connected when the green remote status bar appears in the lower-left corner.

After connecting:

  • Use File → Open Folder...
  • Choose a folder on the remote host

You'll now be able to work on your remote project just like you would locally—with autocomplete, version control, and integrated terminal.

  1. Open the Command Palette
  2. Run Remote-SSH: Open SSH Configuration File...
  3. Add, edit, or remove hosts

Any changes to this file immediately reflect in your Remote SSH host list.

  • If VS Code hangs during connection, run: Remote-SSH: Kill VS Code Server on Host...
  • If you get permission errors, ensure your private key (~/.ssh/id_ed25519) and config files have chmod 600
  • Use the "Remote-SSH" output log for debugging details

If you use Graphite to manage stacked pull requests:

  1. Install the Graphite CLI on your local machine:

    Terminal
    brew install graphite-cli
  2. While connected via Remote SSH in VS Code, install the Graphite extension from the Marketplace

  3. Launch it using the sidebar icon or via Command Palette → Graphite: Open Graphite interactive

You can now interact with your Git stack, create PRs, and view PR history—all inside VS Code on your remote machine.

  • Port forwarding: Add this to your SSH config to forward ports for local testing:

    Terminal
    LocalForward 8080 localhost:8080
  • Dev containers: Use the Dev Containers extension with Remote SSH to run and develop in isolated containers on your remote host.

To disconnect, simply close the VS Code window or go to File → Close Remote Connection. The next time you want to connect, your host configuration will still be available.

This guide has covered how to configure SSH in VS Code, connect to remote machines using the Remote SSH extension, manage SSH configuration, and integrate the Graphite VS Code extension. With this setup, you're ready to work on remote codebases with the same convenience as local development—while also optimizing your pull request workflow using Graphite.

Built for the world's fastest engineering teams, now available for everyone