- Indiana University Indiana University Indiana University
- Use X forwarding on a personal computer to securely run graphical applications installed on IU’s research supercomputers
- Overview
- Requirements
- Use SSH with X forwarding
- Linux or macOS
- PuTTY for Windows
- Use X forwarding for interactive sessions
- On Carbonate
- On Big Red 3
- Get help
- Is it possible to enable X11 forwarding on windows to windows?
- 2 Answers 2
- How to set up working X11 forwarding on WSL2
- 20 Answers 20
- Prerequisite
- How to forward X-server connection
- How to forward any TCP connection back to host
- How to forward any TCP connection from host into WSL2
- Performance
- How to Setup X11 forwarding in WSL2
Indiana University Indiana University Indiana University
Use X forwarding on a personal computer to securely run graphical applications installed on IU’s research supercomputers
Overview
The X Window System (also known as X11, or just X) is a software package and network protocol that lets you interact locally, using your personal computer’s display, mouse, and keyboard, with the graphical user interface (GUI) of an application running on a remote networked computer.
You can use X forwarding in an SSH session on your personal computer to securely run graphical applications (X clients) installed on the Indiana University research supercomputers.
Requirements
For X forwarding in SSH to work, your personal computer must be running an X server program. The X server program manages the interaction between the remote application (the X client) and your computer’s hardware.
Most Linux distributions have the X server installed, but if your personal computer is running Windows or macOS, you will most likely need to install and run an X server application. For example:
- For Windows, download and install Xming. For X forwarding to work, you’ll need to start Xming before connecting to the remote system with your SSH client (for example, PuTTY).
- For macOS, download and install XQuartz. For X forwarding to work, you’ll need to start XQuartz before making an SSH connection to the remote system. Once XQuartz launches, you can use X forwarding with SSH from the Terminal or from the xterm application in XQuartz.
Additionally, your personal computer’s SSH terminal application must have X11 forwarding enabled:
- In Linux, the SSH terminal supports X forwarding by default.
- In macOS, you may need to edit your ssh_config file (typically found at /etc/ssh/ssh_config or
/.ssh/config ) if you have trouble using X forwarding. If ssh_config includes #X11Forwarding no (or just X11Forwarding no ), uncomment out the line (remove the leading # ), and change it to X11Forwarding yes .
Also, the remote computer’s SSH application must be configured to accept X server connections. The IU research supercomputers all have SSH configured to allow X forwarding (trusted mode only).
Use SSH with X forwarding
Linux or macOS
To use SSH with X forwarding on your Linux or macOS personal computer to run an X client application installed on an IU research supercomputer:
- Open your SSH terminal client.
- On the command line, enter (replacing username with your IU username):
- For Big Red 3:
- For Carbonate:
- Log in with your IU passphrase.
To test if X forwarding is working, try running xclock ; on the command line, enter:
If X forwarding is working, the xclock graphical clock will appear on your personal computer’s desktop.
PuTTY for Windows
To use SSH with X forwarding in PuTTY for Windows:
- Launch your X server application (for example, Xming).
- Make sure your connection settings for the remote system have Enable X11 forwarding selected; in the «PuTTY Configuration» window, see Connection > SSH > X11 .
- Open an SSH session to the desired remote system:
System | Hostname |
---|---|
Big Red 3 | bigred3.uits.iu.edu |
Carbonate | carbonate.uits.iu.edu |
To test if X forwarding is working, try running xclock ; on the command line, enter:
If X forwarding is working, the xclock graphical clock will appear on your personal computer’s desktop.
Use X forwarding for interactive sessions
On Carbonate
On Carbonate, if your interactive session requires:
- Less than 20 minutes of processor time: Connect via SSH with X forwarding enabled, and then launch the X client from the command line.
- More than 20 minutes of processor time: Submit a request for an interactive job via the batch system; for help, see the Interactive jobs section of Use Slurm to submit and manage jobs on high performance computing systems.
On Big Red 3
On Big Red 3, submit a request for an interactive job with X11 forwarding in the debug or general partition, and then launch your X application from a compute node:
- SSH to Big Red 3 with X forwarding enabled.
- On the command line, use the Slurm srun command with the —x11 flag to request an X11-enabled interactive session in the debug or general partition; for example:
Once you are placed on a compute node, you can launch graphical X applications (for example, xterm ), as well as your own binaries, from the command line. Depending on the application and your
/.modules file, you may need to load the module for the desired X client before launching the application.
Get help
Support for IU research supercomputers, software, and services is provided by the Research Technologies division of UITS. To ask a question or get help, contact UITS Research Technologies .
This is document bdnt in the Knowledge Base.
Last modified on 2021-04-11 07:02:57 .
Is it possible to enable X11 forwarding on windows to windows?
I managed to connect to a win10 through putty, using newest openssh.
I am not sure it is so-called Microsoft support the ssh. And whether the openssh is almost fully functional.
While, at least i can connect to it through putty(kitty actually). I tried to set X11. Of course I know how to config x11, like localhost:0 and enable X11Forwarding.
Then I tried to execute sublime_text.exe through ssh. The process is up but no UI, is it possible to make X11 up? Or something like X11 that support win-system?
2 Answers 2
To get X11 forwarding working over ssh, you’ll need 3 things in place. 1.Your client must be set up to forward X11. 2.Your server must be set up to allow X11 forwarding. 3.Your server must be able to set up X11 authentication.
If you have both #1 and #2 in place but are missing #3, then you’ll end up with an empty DISPLAY environment variable.
X11 forwarding needs to be enabled on both the client side and the server side.
On the client side, the -X (capital X) option to ssh enables X11 forwarding, and you can make this the default (for all connections or for a specific conection) with ForwardX11 yes in
On the server side, X11Forwarding yes must specified in /etc/ssh/sshd_config. Note that the default is no forwarding (some distributions turn it on in their default /etc/ssh/sshd_config), and that the user cannot override this setting.
The xauth program must be installed on the server side. If there are any X11 programs there, it’s very likely that xauth will be there. In the unlikely case xauth was installed in a nonstandard location, it can be called through
/.ssh/rc (on the server!).
Note that you do not need to set any environment variables on the server. DISPLAY and XAUTHORITY will automatically be set to their proper values. If you run ssh and DISPLAY is not set, it means ssh is not forwarding the X11 connection.
To confirm that ssh is forwarding X11, check for a line containing Requesting X11 forwarding in the ssh -v -X output. Note that the server won’t reply either way.
How to set up working X11 forwarding on WSL2
When moving from WSL1 to WSL2 many things change; apparently this applies to X11 forwarding as well.
What steps do I need to make in order to use X11 forwarding with WSL2 on Windows 10 as I did with WSL1?
20 Answers 20
Add the following to your
Enable Public Access on your X11 server for Windows.*
Add a separate inbound rule for TCP port 6000 to the windows firewall in order to allow WSL access to the X server, as described by the wsl-windows-toolbar-launcher people.
As pointed out by WSL_subreddit_mod on reddit and as you can read in Microsoft’s documentation on WSL2, the WSL2 architecture uses virtualized network components. This means that WSL2 has a different IP address than the host machine. This explains why the X11 forwarding settings of WSL1 cannot simply be transferred to WSL2.
On the Ubuntu Wiki page about WSL you can already find a configuration adapted for WSL2 under Running Graphical Applications. A similar configuration is also suggested by the above mentioned Reddit User, who also contributes another part of the solution: Enable Public Access on the X11 server under Windows.
This means add the following to your
And Enable Public Access on your X11 server for Windows.*
The most important part to enable X11 forwarding for WSL2 on Windows 10 is still missing: the Windows firewall blocks connections via the network interface configured for WSL by default.
A separate inbound rule for TCP port 6000 is required to allow WSL access to the X server. After the rule has been created, as described by the wsl-windows-toolbar-launcher people, the IP address range can be restricted to the WSL subnet in the settings of the newly created rule, under Scope: 172.16.0.0/12.
*: If you use VcXSrv you can enable public access for your X server by disabling Access Control on the Extra Settings:
Or by calling vcxsrv.exe directly with the ac flag: vcxsrv.exe -ac as pointed out by ameeno on the github issue.
For some people who allowed only for private networks like me,
although they Should have been Both Ticked
It should have stop signs on Windows Defender firewall
Double click it and allow the connection for both private and public,
So all the 4 items should be ticked green.
Then the above answer from @NicolasBrauer was working for me.
Like disabling the access control when you XLaunch and
Using /etc/resolv.conf nameserver won’t work for me since I disabled resolv.conf generation in /etc/wsl.conf (I have a custom resolv.conf ).
Ultimately you want the WSL2 host IP address, which should also be your default route. Here’s my
/.bashrc entry for my Debian WSL2 distro:
Copied my answer from this github issue.
The idea is to use the ability to communicate over stdio.
Prerequisite
- Just so we can use socat in Windows host, you need a distribution running WSL1. I am sure you can do this in powershell but I didn’t have time to research this. Maybe someone can write a stdio->tcp redirector in powershell, then we wouldn’t need to have 2 WSL distros.
How to forward X-server connection
- Have your favorite X server running on Windows. By default they would listen to port 6000.
- In the WSL2 distro, run the following command in the background ( ubuntu is the name of the WSL1 distro with socat installed):
Basically this sets up a tunnel from the normal X unix domain socket into the host’s port 6000.
How to forward any TCP connection back to host
Let’s assume there is a tcp service running at port 5555 on Windows. In the WSL2 distro, run the following command in the background ( ubuntu is the name of the WSL1 distro with socat installed):
How to forward any TCP connection from host into WSL2
This is simply doing the same thing, but in the opposite direction. You can run the following in your WSL1 distro:
Performance
On my PC, it can handle up to 150MB/s of data so it’s not the fastest but fast enough for most applications.
For those who may work with simulation engines such as ROS/Gazebo, Unity and so on, another configuration is needed.
Be sure to enable both Public Access and Private Access for your X11 server in windows. Also disable any access control your X11 server supports.
If you use VcXSrv uncheck Native opengl. Final config for VcXSrv will be like:
Alternative good X11 servers with less difficulties are X410 and MobaXterm. For some details about this configuration refer here and here.
How to Setup X11 forwarding in WSL2
This answer assumes that you already have a working XServer and PulseAudio configuration running on your Windows host because you already were using WSL1. (You also may have to add the -ac parameter to the command line to get your XServer of choice to work with WSL2.)
The way that I do this, and to ensure that I get X11 forwarding no matter whether I am using a static IP address or DHCP on the Windows host, or even whether my hostname or network location changes, I add the following to my
After doing the above, no matter what my Hostname or IP address of the Host is, it will be placed in the environment each time a BASH session is started in WSL2. Test it by running firefox from the command line and watch a YouTube video. You should be able to hear the sound as well as see the app itself to watch the video. Test by launching other GUI apps from the command line in addition.
What it does: It uses the host command to pull the IPv4 Addresses associated with the Hostname from the output, greps the address that matches the line that contains your Windows Host IPv4 address, strips the rest of the information except for the IP Address, and then awks that and prints it into the variable, with the output trimmed. This then is used to provide the necessary IP address as a string for use in the environment variables that allow for forwarding of X11 and sound output.
Hopefully it works for you if the other methods don’t work for you (as they didn’t for me).
Most CLI apps can be run either from the BASH Prompt or from Windows Terminal. If you want to make a shortcut, most CLI apps can be set up like either of the following examples (no need for X11 forwarding in such cases except apps like Links2):
If you want to create desktop shortcuts for Linux GUI apps, unless you can get the environment variables from your
/.bashrc file to be used before launching the programs, you will have to create shortcuts using the following template, and put the program name in place of
You do not have to place the full command line for many programs. For PERL-based programs or Python-based programs, you sometimes will have to add the path for PERL and PYTHON, as well as your program’s full path, to run such GUI programs in Linux using WSL2. For one of my perl programs, I have to do it this way:
You may have to experiment a bit to get some apps working properly. For example, you might need to dbus-launch an app, and will need to add that command to the shortcut just before the program name.
And you might have to use a shorter variable name in some circumstances. Some apps just won’t work well, if at all, but this situation is improving over time. Also, don’t try to run the above from a Windows Command Prompt or from PowerShell. It will throw errors about ‘grep’ not being recognized as an internal or external command, etc.
Following is a screenshot of a few Linux GUI apps running on my Windows 10 system, with working X11 forwarding on WSL2.