Use the Tailscale extension for Visual Studio Code

The Tailscale extension for Visual Studio Code lets you interact with resources in your tailnet from within the VS Code IDE.

Download and install the extension

You can view the extension in the VS Code Marketplace, or open the extension in VS Code.

Using the Machine explorer

You can interact with the machines in your tailnet from the primary sidebar in VS Code. Click the Tailscale icon, open the Tailscale Machine explorer, then select the machine that you want to view.

A screenshot of VS Code with the Tailscale Funnel and Machine explorer panels visible
Tailscale SSH must be enabled on a machine in order to connect to it. Currently, this is only available on Linux devices or macOS devices running our open source tailscale + tailscaled CLI.

Connecting to a machine in your tailnet

You can start a new terminal session or attach VS Code to a machine for remote development in one click. Hover over the machine you’d like to connect to, then click either the VS Code Terminal Icon icon to start a terminal session, or the VS Code Remote Explorer Icon icon to attach the VS Code window to the machine.

Resolving common issues with SSH usernames

If you are using the VS Code remote connection feature and your username on the remote instance is different from your local username, you’ll need to specify the remote username in your local SSH configuration. Otherwise, you may encounter connection issues.

Follow the steps below to configure your SSH settings:

  1. Find the remote instance by opening the Tailscale machine explorer. Right-click on the node you want to connect to, and select Copy DNS name.
  2. Edit your SSH configuration by opening your local SSH configuration file. This is typically located in ~/.ssh/config.
  3. Add the remote user configuration by inserting a new section into the configuration file for the remote server. Replace my-server.example.ts.net with the copied DNS name from the first step and alice with your remote username.
Host my-server.example.ts.net
  User alice

By configuring the SSH settings with the correct remote username, you should be able to successfully connect to the remote instance using VS Code.

Editing files on a machine in your tailnet

To view and edit files on a machine in your tailnet, expand the machine, then click the File explorer item. You must have enabled Tailscale SSH on the machine in order to use the file explorer.

The first time you open the file explorer for a machine, you’ll be asked for an SSH username to use for that machine. This username will be locally cached to use for future connections to this machine. If you’d like to change the SSH username later, right-click on the machine and select Change SSH username from the context menu.

You can add new files or directories in the file explorer by right-clicking on a directory and selecting New file or New directory. To rename or delete an existing file or directory, right-click on the item and select Rename or Delete from the context menu.

Deleting a file or folder from the file explorer is a permanent action and cannot be undone.
Changing the root directory

By default, the File explorer will open the home folder (~/) of the username you provided. You can change the root folder by right-clicking on the machine and selecting Change root directory from the context menu.

Start Tailscale Funnel

You can easily set up Tailscale Funnel inside of VS Code using the command palette or the Tailscale panel view. You must have Funnel enabled in your tailnet ACLs in order to take advantage of this feature.

The VS Code extension allows you to expose one port on your local machine to the public internet with Funnel. To expose multiple ports, use the Funnel CLI.

To use Funnel, you must enable MagicDNS and HTTPS certificates in the admin console, and add the appropriate node attribute (nodeAttrs) to your tailnet policy file.

Using the Funnel panel

  1. Open the panel. You can use the keyboard shortcut CMD + J.
  2. Enter the local port you want to expose over the internet in the port field.
  3. Click Start to begin serving this port over the internet.

You can open the public URL in your default browser or copy it to your clipboard. To edit the existing Funnel configuration in this panel, change the port number and click the Update button.

Using Funnel from the command palette

  1. Open the command palette with the keyboard shortcut CMD + Shift + P.
  2. Type Tailscale to view all of the extension’s commands.
  3. To start Tailscale Funnel, choose Tailscale: Share port publicly using Funnel.
  4. Enter the port number that you wish to share via Funnel.

Port discovery

When you start a local server from VS Code, Tailscale will ask if you’d like to share that port over the internet with Funnel.

Troubleshooting

Troubleshooting the machine explorer in the VS Code extension

If the Machine explorer isn’t working as expected, we recommend the following steps:

  1. Check that Tailscale SSH is enabled on the machines you want to connect to. For now, this functionality is only available on Linux devices and macOS devices running our open source tailscale + tailscaled CLI. This means that some features of the Machine explorer won’t work for Windows devices, iOS/Android devices, or macOS devices running the App Store or standalone Mac app.
  2. Check that your ACLs are set to allow Tailscale SSH access between your local machine and the machine you want to connect to.
  3. Ensure that you’re using a valid username that already exists on the machine. If you need to change the username to something else, right-click on the machine and select Change SSH username from the context menu.

Troubleshooting Funnel in the VS Code extension

If Funnel isn’t working as expected, we recommend the following steps:

  1. Check to ensure that Tailscale is signed in and active. On macOS and Windows, you can do this by clicking the Tailscale icon in your OS status bar. On Linux, run tailscale status in your CLI. If you have signed in to multiple Tailscale accounts on your device, ensure that the correct account is active.
  2. Ensure that your tailnet access controls (ACLs) are configured to allow Tailscale Funnel on your device.
  3. Ensure that MagicDNS and HTTPS Certificates are enabled on your tailnet.
  4. Ensure tailscale is available in the environment path. You can check this by running tailscale status in your CLI; if no command is found, you may need to add the Tailscale executable to your path. Alternatively, you can set its path via the tailscale.path setting in VS Code.

Configuration

  • tailscale.path: A path to the tailscale executable. If unset, the extension will use the environment path to resolve the tailscale executable. If set, the extension will use the supplied path. The path should include the executable name (for example, /usr/bin/tailscale, C:\Program Files\tailscale\tailscale.exe).