VS Code allows you to open a remote folder on any virtual machine, container,
or environment with a running SSH server, allowing developers to interact
with files and folders on the remote filesystem. Remote workspaces are
helpful when using a separate environment to edit, build, or run Fuchsia.

![This diagram shows the difference between your local VS Code and
SSH environment. VS Code uses an SSH tunnel to communicate with your
external environment where you can work on Fuchsia.](https://fuchsia.dev/static/fuchsia-src/reference/tools/editors/vscode/images/remote-workspaces/ssh-diagram.jpg)

Configuring remote workspaces involve the following steps:

1. [Prerequisites](https://fuchsia.dev/fuchsia-src/reference/tools/editors/vscode/remote-workspaces#prerequisites)
2. [Connect to remote workspace](https://fuchsia.dev/fuchsia-src/reference/tools/editors/vscode/remote-workspaces#connect-to-remote-workspace)
3. [Disconnect remote workspace](https://fuchsia.dev/fuchsia-src/reference/tools/editors/vscode/remote-workspaces#disconnect-remote-workspace)

## Prerequisites

Before you start, complete the following tasks:

- [Install VS Code](https://code.visualstudio.com/docs/setup/setup-overview)
- [Install SSH extension](https://fuchsia.dev/fuchsia-src/reference/tools/editors/vscode/remote-workspaces#install-ssh-extension)

### Install SSH extension

To connect to a remote host for the first time, install Microsoft's Remote SSH
Extension in VS Code:

1. In VS Code, launch **Quick Open** by running `CMD/CTRL + P`.
2. Paste the following command in the text prompt and press enter:

       ext install ms-vscode-remote.remote-ssh

## Connect to remote workspace

After [installing the SSH extension](https://fuchsia.dev/fuchsia-src/reference/tools/editors/vscode/remote-workspaces#install-ssh-extension), connect to your
SSH environment:

1. Press `F1` or `CMD/CTRL + SHIFT + P` to open **Command Palette**.
2. Type in the field, `Remote-SSH: Connect to Host...` and press enter. ![This figure shows the command palette field in VS Code. The field
   contains the text Remote-SSH.](https://fuchsia.dev/static/fuchsia-src/reference/tools/editors/vscode/images/remote-workspaces/command-palette.png)
3. Type in the domain name of your SSH environment and press enter:

       username@hostname.com

4. If VS Code cannot detect the type of server, select **Linux** manually.
   ![This figure shows a dropdown menu in VS Code to select the type of
   server.](https://fuchsia.dev/static/fuchsia-src/reference/tools/editors/vscode/images/remote-workspaces/select-platform.png)

5. After connecting, the bottom left status bar displays your current SSH session.

## Disconnect remote workspace

To close the connection with the remote host, you can either:

- Exit VS Code.
- In VS Code's navigation, click **File** then **Close Remote Connection**.

## Troubleshooting

For additional support, VS Code provides [official documentation](https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host)
for troubleshooting scenarios.
[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/reference/tools/editors/vscode/remote-workspaces.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/reference/tools/editors/vscode/remote-workspaces.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/reference/tools/editors/vscode/remote-workspaces.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/reference/tools/editors/vscode/remote-workspaces.md "Edit the source code of this page")