GitHub Copilot in VS Code With Remote Tunnels: Setup Walkthrough
🔍 WiseChecker

GitHub Copilot in VS Code With Remote Tunnels: Setup Walkthrough

You want to use GitHub Copilot in Visual Studio Code while editing code on a remote machine, a cloud server, or a device behind a firewall. Remote Tunnels let you connect VS Code on your local computer to a remote environment without complex VPN or SSH configuration. This article explains how to install the Remote Tunnels extension, pair it with GitHub Copilot, and start writing code on any machine with an internet connection.

GitHub Copilot provides AI-powered code suggestions directly in the editor. Remote Tunnels create a secure encrypted link between your local VS Code instance and a remote VS Code Server. The combination allows you to use Copilot on a remote file system as if the files were local. The setup requires both extensions installed and a GitHub account with an active Copilot subscription.

Key Takeaways: GitHub Copilot and Remote Tunnels in VS Code

  • Remote Tunnels extension (ms-vscode.remote-server): Creates a secure tunnel from your local VS Code to a remote VS Code Server instance.
  • GitHub Copilot extension (GitHub.copilot): Provides AI code suggestions on the remote machine through the tunnel connection.
  • VS Code Server on the remote machine: Must be installed and running; the tunnel uses the same GitHub account for authentication.

ADVERTISEMENT

How Remote Tunnels Work With GitHub Copilot

Remote Tunnels is a VS Code extension that establishes a secure WebSocket connection between your local VS Code client and a VS Code Server running on a remote machine. The remote machine can be a cloud VM, a Raspberry Pi, a container, or any computer with internet access. The tunnel does not require opening firewall ports or configuring SSH keys. The connection is encrypted end-to-end using TLS.

GitHub Copilot works by sending code context from the active editor to the Copilot service, which returns suggestions. When you use Remote Tunnels, the Copilot extension runs on the remote VS Code Server. The code context is sent from the remote server to the Copilot API, not from your local machine. This means the remote machine must have outbound HTTPS access to api.github.com and copilot-proxy.githubusercontent.com.

The authentication flow uses your GitHub account. Both the local VS Code and the remote VS Code Server sign in with the same GitHub account. Copilot licensing is tied to your GitHub user account, so no separate license key is needed on the remote machine. The remote server uses the GitHub token stored on the remote to authenticate with Copilot services.

Prerequisites

  • Visual Studio Code installed on your local machine version 1.82 or later.
  • An active GitHub Copilot subscription Copilot Individual, Copilot Business, or Copilot Enterprise.
  • A remote machine with a supported operating system Linux, Windows, or macOS with internet access.
  • The remote machine must have VS Code Server installed. The Remote Tunnels extension handles this automatically on first connection.

Steps to Set Up GitHub Copilot With Remote Tunnels

  1. Install the Remote Tunnels extension on your local VS Code
    Open VS Code on your local computer. Go to the Extensions view by pressing Ctrl+Shift+X. Search for Remote Tunnels published by Microsoft. Click Install. The extension identifier is ms-vscode.remote-server.
  2. Install the GitHub Copilot extension on your local VS Code
    In the same Extensions view, search for GitHub Copilot published by GitHub. Click Install. Sign in with your GitHub account when prompted. Accept the required permissions for Copilot to read the open file and editor context.
  3. Start a remote tunnel from the remote machine
    On the remote machine, open a terminal. Run the command: code tunnel. If VS Code Server is not installed, the command downloads and installs it automatically. The first run prompts you to authenticate with GitHub. Follow the URL printed in the terminal to authorize the device. After authentication, the tunnel starts and displays a name or code for the tunnel.
  4. Connect your local VS Code to the remote tunnel
    On your local VS Code, open the Command Palette with Ctrl+Shift+P. Type Remote Tunnels: Connect to Tunnel. Select the tunnel name from the list. If the tunnel does not appear, enter the tunnel name or code manually. VS Code opens a new window connected to the remote machine.
  5. Install Copilot on the remote VS Code Server
    In the remote VS Code window, open the Extensions view again. The view now shows extensions for the remote server. Search for GitHub Copilot and click Install on the remote. The extension is installed on the remote VS Code Server, not on your local machine. Sign in with the same GitHub account used on your local VS Code.
  6. Verify Copilot is active on the remote
    Open a code file on the remote machine through the tunnel. Start typing code. Copilot should display ghost text suggestions. Press Tab to accept a suggestion. If suggestions do not appear, open the Output panel and select the Copilot log channel to check for authentication errors.

ADVERTISEMENT

Common Issues and How to Resolve Them

Copilot does not show suggestions on the remote machine

The most common cause is that Copilot is installed only on the local VS Code, not on the remote VS Code Server. Open the Extensions view while connected to the remote tunnel. Verify that GitHub Copilot appears under the Remote section, not the Local section. If it shows only locally, click Install on the remote. Another cause is network restrictions. The remote machine must be able to reach api.github.com on port 443. Check firewall rules and proxy settings on the remote machine.

Remote tunnel connection fails with authentication error

The tunnel authentication uses a device code flow. If the code expires before you complete the authorization, run code tunnel again on the remote machine. On the local side, ensure you are signed into the same GitHub account in VS Code. Open the Accounts view in VS Code and check the GitHub account shown. If accounts do not match, sign out and sign back in with the same account on both sides.

Copilot returns generic suggestions instead of project-specific ones

Copilot uses the open file and the recently opened files in the workspace to provide context. On a remote tunnel, the workspace is the folder on the remote machine. If the remote workspace does not contain the project files, Copilot has no context. Open the correct folder on the remote machine using File > Open Folder in the remote VS Code window. Also verify that the remote machine has the project dependencies installed so Copilot can infer patterns from imports and configuration files.

Tunnel disconnects frequently

Remote Tunnels use a persistent WebSocket connection. Unstable internet on either side causes disconnections. On the remote machine, ensure the terminal session running code tunnel stays active. Use a process manager like systemd on Linux or a terminal multiplexer like tmux to keep the tunnel running after you close the SSH session. On the local side, a wired connection reduces disconnections.

Remote Tunnels vs SSH Remote Development: Key Differences

Item Remote Tunnels SSH Remote Development
Setup complexity No SSH configuration or port forwarding needed Requires SSH server setup, key management, and firewall rules
Authentication GitHub device code flow SSH keys or password-based login
Network requirements Outbound HTTPS to GitHub only Inbound SSH port 22 must be open
Performance Latency depends on internet speed to GitHub relay Direct connection, lower latency
File system access Remote machine file system only Remote machine file system only
Copilot compatibility Requires Copilot installed on remote server Copilot runs on remote machine automatically

Next Steps After Setup

You can now edit code on any remote machine using GitHub Copilot through a secure tunnel. The tunnel persists across VS Code restarts on the local side as long as the remote tunnel process continues running. To stop the tunnel on the remote machine, press Ctrl+C in the terminal where code tunnel is running.

Try opening a project on the remote machine and using Copilot Chat by pressing Ctrl+I or clicking the Copilot icon in the activity bar. Copilot Chat uses the same tunnel connection and provides inline code explanations and refactoring suggestions based on the remote workspace. For multi-developer scenarios, each user must have their own Copilot subscription and authenticate separately on the remote machine.

ADVERTISEMENT