When working in a remote environment,this extension sets the DISPLAY
environment variable so that X windowsapplications started from Visual Studio Code appear on the local machine.
- Visual Studio Code Remote Code Execution Vulnerability
- Visual Studio Code Remote Rust
- Visual Studio Code Remote Ssh Settings
For this extension to work, it must be installed on the remote machine, and youmust be running an X server on the local machine. For SSH connections, theRemote X11 (SSH)extension must also be installed on the local machine (this should be installedautomatically when you install this extension).
You may need to change some settings for this to work with SSH! Please checkthe 'Authentication Settings' section below, as this extension cannot use VS Code'sSSH authentication, and it does not support all SSH authentication methods.
For Windows hosts, this extension has only been tested with VcXsrv,but other servers such as Cygwin/X, Xming,and X410 should also work. Windows remotes arenot currently supported.
Visual Studio Code Remote Extension; This allowed me to edit my Raspberry Pi files from within Visual Studio Code. So, I get all the joys of writing code directly on my Raspberry Pi, but with all the bells-and-whistles of Visual Studio Code (VSC). For the most part, setup is pretty straightforward. But the Pi side can get tricky, so I’m going. It can be done over the terminal. (VS code has a terminal) Go to the root of the directory. List your existing remotes in order to get the name of the remote you want to change. For those of you that are familiar with the ISE, you may recall that you could run psedit file.ps1 from the integrated console to open files - local or remote - right in the ISE. This feature is also available in the PowerShell extension for VSCode. This guide shows you how to do it.
Create Remote Github Repository In VS Code In order to set up a remote repo, usually we need to open browser and create a repo in github manually, and then push the local repo to it. With Remote - Github, you can create remote github repo right in VS Code and sync with your local repo automatically. Install VS Code and the Remote WSL extension. Visit the VS Code install page and select the 32 or 64 bit installer. Install Visual Studio Code on Windows (not in your WSL file system). When prompted to Select Additional Tasks during installation, be sure to check the Add to PATH option so you can easily open a folder in WSL using the code command.
For SSH connections, if the remote machine does not have Bash installed, youmust change the remoteX11.SSH.displayCommand
setting and provide a commandthat prints the value of the DISPLAY
variable. If you are using portforwarding, you may also need to change the remoteX11.SSH.port
setting. Seebelow for more details.
Access Control
For containers and WSL 2, you will need to eitherauthorize with your X serveror disable access control.
For SSH and WSL 1 targets, connections to the X server will come from the localmachine, so you should not need to configure anything for these to work.
X11 Forwarding
The Remote - SSH extension doesnot currently enable X11 forwarding ([see issue #267](https://github.com/microsoft/vscode-remote-release/issues/267)).To work around this, the Remote X11 (SSH)extension creates an SSH connection to the remote machine with forwardingenabled in the background.
This extension currently only supports public key authentication. See belowfor more details on authentication settings.
Extension Settings
Changes to settings will normally apply automatically after a short delay. Youmay need to restart any terminals if setting changes result in the DISPLAY
variable changing.
You can also use F1 > Remote X11: Reconnect Display
to force an update.
remoteX11.display
- Display number to connect to. Change this if your X serveris using a display other than 0.remoteX11.screen
- Screen number to connect to.remoteX11.container.enable
- SetDISPLAY
for containers?remoteX11.SSH.enable
- Enable X11 forwarding and setDISPLAY
for SSH targets?remoteX11.SSH.authenticationMethod
:keyFile
- Authenticate with the private key file specified byremoteX11.SSH.privateKey
.Passphrase-protected keys are not supported.agent
- Usessh-agent
to get keys. This method does support passphrase-protected keys.
remoteX11.SSH.agent
- Name of a Unix socket or Windows named pipe for ssh-agent.Set topageant
to use Pageant on Windows. If left empty, defaults to Windows 10's OpenSSHagent (.pipeopenssh-ssh-agent
) or theSSH_AUTH_SOCK
environment variable on other platforms.Only used ifremoteX11.SSH.authenticationMethod
isagent
.remoteX11.SSH.privateKey
- Absolute path to your SSH private key file.Only used ifremoteX11.SSH.authenticationMethod
ispublicKey
.remoteX11.SSH.XAuthPermissionLevel
- Select between untrusted (ssh -X
) and trusted (ssh -Y
) permissions.remoteX11.SSH.X11ConnectionType
- Select between TCP and Unix sockets for the X11 connection.Defaults totcp
on Windows hosts orunix
otherwise.remoteX11.SSH.X11Socket
- Selects the Unix socket to connect to. The screen number is appended to the end ofthis setting.remoteX11.SSH.displayCommand
- A command which printsDISPLAY=<DISPLAY>
followed by a newline,where<DISPLAY>
is the value of theDISPLAY
variable. Note that there must not be any spacesin this text. Change this when connecting to a machine that doesn't support the default command.remoteX11.SSH.timeout
- Number of seconds to wait for the SSH shell to respond to the above command.Use0
to wait forever.remoteX11.SSH.host
- Sets the hostname or IP address used to connect to the SSH server.Use this if Remote X11 tries to connect to the wrong address.remoteX11.SSH.port
- Sets the port used to connect to the SSH server. Use this ifRemote X11 tries to connect to the wrong port.remoteX11.WSL.enable
- SetDISPLAY
for WSL targets?
Authentication Settings
Remote X11 currently only supports public key authentication. You must usessh-keygen
to generate a public/private key pair and add your public key toyour server's ~/.ssh/authorized_keys
file.
There are two ways RemoteX11 can be configured to get keys:
Private Key File
If the remoteX11.SSH.authenticationMethod
setting is keyFile
, Remote X11 willread the file given by the remoteX11.SSH.privateKey
file as your private key.This defaults to ~/.ssh/id_rsa
, so you must change it if your file is nameddifferently.
This method does not support passphrase-protected private keys! See belowfor methods that do.
SSH Agent
If the remoteX11.SSH.authenticationMethod
setting is agent
, Remote X11 willuse ssh-agent
to read keys added with ssh-add
.See the VS Code documentation for instructions on enabling the SSH Agent.
To add your key to the SSH agent, open a terminal on the local machine and run:
Garage sales near me today craigslist. If your key is passphrase-protected, you will be prompted to enter the passphrase.You can then log in without re-entering the passphrase.
On Windows, you can also use Pageantinstead of the built-in OpenSSH agent by changing the remoteX11.SSH.agent
setting to pageant
.
Troubleshooting
Is the extension installed?
When in a remote workspace, open the Extensions view (Ctrl+X) and check that'Remote X11' is installed and enabled on the remote machine. If you are using anSSH connection, also check that 'Remote X11 (SSH)' is installed and enabled onthe local machine.
Check the logs
When in a remote workspace, open the Output pane (Ctrl+Shift+U) and use thedrop-down list in the upper-right to check the logs from 'Remote X11'. Ifeverything is working correctly, the logs should show something similar to:
If not, the error message may help you figure out the problem. Solutions to somecommon errrors are listed below.
Are the SSH address and port correct?
By default, Remote X11 uses the SSH_CONNECTION
variable to determine theaddress and port to the SSH server. This may be incorrect if you are usingfeatures such as port forwarding.
Check the logs for the 'connecting to SSH ..' message and check that theaddress and port are correct. If not, fix them with the the remoteX11.SSH.host
and/or remoteX11.SSH.port
settings. Note that these settings must be set onthe remote machine, so open a remote workspace and use the Remote tab ofsettings to change them.
Is your X server running?
If you see DISPLAY = ..
in the Remote X11 logs but nothing shows up when yourun a GUI application, make sure your X server is running on your local machine.
Visual Studio Code Remote Code Execution Vulnerability
Also make sure the remoteX11.display
setting matches the display number yourX server is set to use.
Are you using the correct connection type?
X11 servers on Windows typically use a TCP connection, and servers on Unix-basedsystems typically use a Unix socket. When remoteX11.SSH.X11ConnectionType
isauto
, it will select between TCP and Unix sockets accordingly. If the automaticselection is not correct, you can manually change it to use TCP or Unix sockets.
Is SSH able to find the display?
If you are using SSH and don't see DISPLAY = ..
in the logs, check the logsfrom 'Remote X11 (SSH)' for errors as well. Near the end of the logs should bea command to print out the DISPLAY
variable. If this command is failing, trychanging it with the remoteX11.SSH.displayCommand
setting in your user (notremote) settings.

Cannot parse privateKey: Encrypted OpenSSH private key detected, but no passphrase given
Passphrase-protected keys are not supported with the default authenticationmethod. Gdpr is coming!. You must use an SSH Agent instead. See Authentication Settings abovefor more details.
All configured authentication methods failed
Check your authentication settings. This usually means that either your publickey is not in the remote server's authorized_keys
file, or you haven't addedyour private key to your SSH agent. See Authentication Settings above formore details.
ENOENT: .pipeopenssh-ssh-agent

Windows' SSH Agent is probably not running. From the Start menu, open 'Services'and make sure the OpenSSH Authentigation Agent service is running.
Authorization required, but no authorization protocol specified
Access control is enabled on your X server. Either authenticate with the serveror disable access control. See https://en.wikipedia.org/wiki/X_Window_authorizationfor more details.
Error: Can't open display: .. on WSL 2
If you get this error when running an application from WSL 2, the connection isprobably being blocked by the Windows firewall. You can edit the firewall rulesto allow it:
From the Start menu, open Windows Defender Firewall, then select 'Advanced settings'from the left sidebar. This should open a window titled 'Windows Defender Firewallwith Advanced Security'
Select 'Inbound Rules' on the left.
Find the rule with the following settings:
- Name: the name of your X server, e.g. 'VcXsrv windows xserver'
- Action: Block
- Protocol: TCP
Right-click the rule and select 'Properties'.
On the General tab, change the action to 'Allow the connection':
On the Scope tab, change 'Remote IP address' to 'These IP addresses'and add the following values:
172.16.0.0/12
192.168.0.0/16
Select OK to save your changes.
See https://github.com/microsoft/WSL/issues/4139 for more details.
Visual Studio Code Remote Rust
Other issues
Visual Studio Code Remote Ssh Settings
If you get any other errors and you can't figure out the cause, create an issueat https://github.com/ChaosinaCan/vscode-remote-x11/issues and post your logsand I'll try to help.
If you are using SSH, please enable the remoteX11.SSH.verboseLogging
settingto log technical details about the SSH connection to the 'Remote X11 (SSH)' logs,and include those in your issue report. This is useful for finding issues suchas the server not supporting the algorithm used by your private key.
