Table of Contents
- Why use SSH in VS Code?
- Prerequisites
- 1. Install the Remote SSH extension
- 2. Verify your SSH setup
- 3. Configure your SSH config file
- 4. Connect using Remote SSH in VS Code
- 5. Open a remote folder
- 6. Edit SSH config from inside VS Code
- 7. Troubleshooting common issues
- 8. Using the Graphite VS Code extension over SSH
- 9. Advanced usage
- 10. Disconnect
- Conclusion
Why use SSH in VS Code?
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.
Prerequisites
- 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. Install the Remote SSH extension
- Open VS Code
- Go to the Extensions tab (sidebar)
- Search for "Remote - SSH"
- Install the Remote - SSH extension by Microsoft
- 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.
2. Verify your SSH setup
In a terminal window, test your SSH connection:
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.
3. Configure your SSH config file
Create or update your SSH config file at ~/.ssh/config
:
Host dev-serverHostName 192.0.2.10User ubuntuIdentityFile ~/.ssh/id_ed25519
This simplifies your commands. Instead of typing the full SSH command, you can use:
ssh dev-server
VS Code will also detect these named hosts for use in the Remote SSH connection interface.
4. Connect using Remote SSH in VS Code
- Open the Command Palette (
F1
orCtrl+Shift+P
) - Type and select Remote-SSH: Connect to Host...
- Choose your host (e.g.,
dev-server
) - 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.
5. Open a remote folder
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.
6. Edit SSH config from inside VS Code
- Open the Command Palette
- Run Remote-SSH: Open SSH Configuration File...
- Add, edit, or remove hosts
Any changes to this file immediately reflect in your Remote SSH host list.
7. Troubleshooting common issues
- 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 havechmod 600
- Use the "Remote-SSH" output log for debugging details
8. Using the Graphite VS Code extension over SSH
If you use Graphite to manage stacked pull requests:
Install the Graphite CLI on your local machine:
Terminalbrew install graphite-cliWhile connected via Remote SSH in VS Code, install the Graphite extension from the Marketplace
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.
9. Advanced usage
Port forwarding: Add this to your SSH config to forward ports for local testing:
TerminalLocalForward 8080 localhost:8080Dev containers: Use the Dev Containers extension with Remote SSH to run and develop in isolated containers on your remote host.
10. Disconnect
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.
Conclusion
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.