Remote Development Tips and Tricks
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Remote Development Tips and Tricks View as Markdown Ask in VS Code Ask in VS Code Insiders This article covers troubleshooting tips and tricks for each of the Visual Studio Code Remote Development extensions.
See the SSH , Containers , and WSL articles for details on setting up and working with each specific extension. Or try the introductory Tutorials to help get you running quickly in a remote environment. For tips and questions about GitHub Codespaces , see the GitHub Codespaces documentation . SSH tips SSH is powerful and flexible, but this also adds some setup complexity. This section includes some tips and tricks for getting the Remote - SSH extension up and running in different environments.
Customize AI Chat Responses Custom instructions enable you to describe common guidelines or rules to get responses that match your specific coding practices and tech stack. You can use custom instructions to give Copilot more information about the type of remote environment you're connected to (like what kind of languages or toolchains are installed). You can use a copilot-instructions.md file just as you would locally.
There are additional instruction configuration steps you can take when using a dev container too. Configuring the $EDITOR variable For macOS / linux remote hosts, add this snippet to your shell configuration file (like .bashrc or .zshrc ) if [ " $VSCODE_INJECTION " = "1" ]; then export EDITOR = "code --wait" # or 'code-insiders' if you're using VS Code Insiders fi For Windows hosts, here is the equivalent PowerShell: if ( $env:VSCODE_INJECTION -eq "1" ) { $env:EDITOR = "code --wait" # or 'code-insiders' for VS Code Insiders } Now running a terminal command that uses the $EDITOR variable, like git commit , will open the file in VS Code instead of the default terminal-based editor (like vim or nano ).
Configuring key based authentication SSH public key authentication is a convenient, high security authentication method that combines a local "private" key with a "public" key that you associate with your user account on an SSH host. This section will walk you through how to generate these keys and add them to a host. Tip: PuTTY for Windows is not a supported client , but you can convert your PuTTYGen keys . Quick start: Using SSH keys To set up SSH key based authentication for your remote host.
First we'll create a key pair and then copy the public key to the host. Create your local SSH key pair Check to see if you already have an SSH key on your local machine. This is typically located at ~/.ssh/id_ed25519.pub on macOS / Linux, and the .ssh directory in your user profile folder on Windows (for example C:\Users\your-user\.ssh\id_ed25519.pub ). If you do not have a key, run the following command in a local terminal / PowerShell to generate an SSH key pair: ssh-keygen -t ed25519 -b 4096 Tip: Don't have ssh-keygen ?
Install a supported SSH client . Restrict the permissions on the private key file For macOS / Linux, run the following shell command, replacing the path to your private key if necessary: chmod 400 ~/.ssh/id_ed25519 For Windows, run the following command in PowerShell to grant explicit read access to your username: icacls "privateKeyPath" /grant <username>:R Then navigate to the private key file in Windows Explorer, right-click and select Properties .
Select the Security tab > Advanced > Disable inheritance > Remove all inherited permissions from this object . Authorize your macOS or Linux machine to connect Run one of the following commands, in a local terminal window replacing user and host name as appropriate to copy your local public key to the SSH host. Connecting to a macOS or Linux SSH host: export USER_AT_HOST = "your-user-name-on-host@hostname" export PUBKEYPATH = " $HOME /.ssh/id_ed25519.pub" ssh-copy-id -i " $PUBKEYPATH " " $USER_AT_HOST " Connecting to a Windows SSH host: The host uses OpenSSH Server and the user belongs to the administrator group : export USER_AT_HOST = "your-user-name-on-host@hostname" export PUBKEYPATH = " $HOME /.ssh/id_ed25519.pub" ssh $USER_AT_HOST "powershell Add-Content -Force -Path \"\$ Env:PROGRAMDATA \\ ssh \\ administrators_authorized_keys \" -Value '$( tr -d '\n\r' < " $PUBKEYPATH ")'" Otherwise: export USER_AT_HOST = "your-user-name-on-host@hostname" export PUBKEYPATH = " $HOME /.ssh/id_ed25519.pub" ssh $USER_AT_HOST "powershell New-Item -Force -ItemType Directory -Path \"\$ HOME \\ .ssh \" ; Add-Content -Force -Path \"\$ HOME \\ .ssh \\ authorized_keys \" -Value '$( tr -d '\n\r' < " $PUBKEYPATH ")'" You may want to validate that the authorized_keys file in the .ssh folder for your remote user on the SSH host is owned by you and no other user has permission to access it.
See the OpenSSH wiki for details. Authorize your Windows machine to connect Run one of the following commands, in a local PowerShell window replacing user and host name as appropriate to copy your local public key to the SSH host. Connecting to a macOS or Linux SSH host: $USER_AT_HOST = "your-user-name-on-host@hostname" $PUBKEYPATH = "$HOME\.ssh\id_ed25519.pub" $pubKey =( Get-Content " $PUBKEYPATH " | Out-String ); ssh " $USER_AT_HOST " "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo ' ${pubKey} ' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" Connecting to a Windows SSH host: The host uses OpenSSH Server and the user belongs to the administrator group : $USER_AT_HOST = "your-user-name-on-host@hostname" $PUBKEYPATH = "$HOME\.ssh\id_ed25519.pub" Get-Content " $PUBKEYPATH " | Out-String | ssh $USER_AT_HOST "powershell `" Add-Content -Force -Path `"`$ Env:PROGRAMDATA\ssh\administrators_authorized_keys `" `" " Otherwise: $USER_AT_HOST = "your-user-name-on-host@hostname" $PUBKEYPATH = "$HOME\.ssh\id_ed25519.pub" Get-Content " $PUBKEYPATH " | Out-String | ssh $USER_AT_HOST "powershell `" New-Item -Force -ItemType Directory -Path `"`$ HOME\.ssh `" ; Add-Content -Force -Path `"`$ HOME\.ssh\authorized_keys `" `" " Validate that the authorized_keys file in the .ssh folder for your remote user on the SSH host is owned by you and no other user has permission to access it.
See the OpenSSH wiki for details. Improving your security with a dedicated key While using a single SSH key across all your SSH hosts can be convenient, if anyone gains access to your private key, they will have access to all of your hosts as well. You can prevent this by creating a separate SSH key for your development hosts. Just follow these steps: Generate a separate SSH key in a different file. macOS / Linux : Run the following command in a local terminal : ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519-remote-ssh Windows : Run the following command in a local PowerShell : ssh-keygen -t ed25519 -f "$HOME\.ssh\id_ed25519-remote-ssh" Follow the same steps in the quick start to authorize the key on the SSH host, but set the PUBKEYPATH to the id_ed25519-remote-ssh.pub file instead.
In VS Code, run Remote-SSH: Open Configuration File... in the Command Palette ( F1 ), select an SSH config file, and add (or modify) a host entry as follows: Host name-of-ssh-host-here User your-user-name-on-host HostName host-fqdn-or-ip-goes-here IdentityFile ~/.ssh/id_ed25519-remote-ssh Tip: You can use / for Windows paths as well. If you use \ you will need to use two slashes. For example, C:\\path\\to\\my\\id_ed25519 .
Reusing a key generated in PuTTYGen If you used PuTTYGen to set up SSH public key authentication for the host you are connecting to, you need to convert your private key so that other SSH clients can use it. To do this: Open PuTTYGen locally and load the private key you want to convert. Select Conversions > Export OpenSSH key from the application menu. Save the converted key to a local location
The rest of this page is on the live site.