Body
Using the X Window System (also known as X11 or just X), you can run graphical programs on a remote Linux machine through an SSH connection. In order to do this, you will need to have an SSH connection to a machine that supports X forwarding with a client that also supports X forwarding, as well as an X server installed and running. Please note that depending on your local computer’s speed and especially your network connection, this can be very slow.
VPN requirement
In this guide, we use Colossus and Guardian as examples. These computers are for students to perform coursework remotely on a Linux machine. Please note that you must have the VPN installed and connected in order to start an SSH connection and use X forwarding. Please visit the Related Articles section for information about connecting to the VPN.
Xpra is a program with similar functionality to X forwarding, but much faster and with helpful additional features. X forwarding should be avoided unless for convenience or if an application does not work through Xpra. Please visit our
KB article for more information about using Xpra.
From a Linux Computer
Almost all distributions will support this out of the box. Even if you run Wayland (in distros such as Fedora), XWayland provides backward compatibility with X. To do this, use the -X flag with your SSH command: ssh -X username@computername
![XWayland screen](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=1a80dab8-e090-403b-b681-154729363a63.png)
Programs launched through X forwarding will usually have a message like this in the title bar saying “(on computername)” to help distinguish that it is running through X forwarding. Your mileage may vary depending on your choice of desktop environment/compositor/implementation of X/etc. The following screenshot was taken on Fedora 31 running Gnome 3.34.4
![X forwarding message that reads, xclock (on colossus.it.mtu.edu)](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=f4e90834-e7ed-44f7-8536-e1b3dfc3467b.png)
From a Windows Computer
From Windows, you need to have an SSH client and an X server installed, as these are not installed by default on Windows. Two popular methods are
- Using MobaXterm, which is a new, feature-rich client
- Using PuTTY with Xming, as PuTTY is a popular SSH client for Windows
Using MobaXterm
MobaXterm is a cool terminal emulator with a ton of features. The home edition is free for use. MobaXterm is available to download.
- Once installed, open MobaXterm. It will be a little slow for the first launch. If you get a prompt for firewall access, select Allow access.
- Start a new session by selecting Session.
![MobaXterm window](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=a15bdf0c-b1d6-40a2-88af-94b1a13becc0.png)
-
In the window that pops up, select SSH, then enter the computer you wish to connect to in the Remote host field. You can check the box for Specify username and enter your username as well. Leave the port set to 22.
-
Select the Advanced SSH settings tab and then make sure the X11-Forwarding box is checked. Leave the rest of the settings at their defaults. Select OK
![Session settings window](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=3a3fda44-7c0a-4cb8-bc06-57e6bb9ba688.png)
-
MobaXterm will start a new SSH session in a tab and prompt for your password. Once authenticated, MobaXterm will display a message with information about the session, followed by any information from the connected computer. From here, you can run commands and open programs normally. MobaXterm will add “@computername” to the title bar of any windows that pop up to show that they are running from an X session.
![MobaXterm session window](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=a820fccd-c85d-4bec-b225-e0d5c36d1fb4.png)
-
From here, you can quickly use the saved user session to reconnect again. The tabs along the left have useful tools, games, and more. The SFTP tab also has an SFTP file browser for quick and easy file transfers between your Michigan Tech home drive and the computer running MobaXterm.
Using PuTTY with Xming
Xming Download Site
Putty Download Site
- Make sure Xming is running; the Xming icon will show in the System Tray if it's active.
![Xming icon in System Tray](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=ffadb81f-97d1-40a6-b702-5e4f813004e0.png)
-
With PuTTY running, scroll down to Connection, then expand SSH and select the X11 tab. Check the box for Enable X11 forwarding.
![PuTTY SSH tab](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=b2b86c20-aec6-4ffb-93f5-23ef81436cfa.png)
-
Scroll back up, select Session at the top and enter a Host Name. Enter a name in the box below Saved Sessions, such as the name of the computer you’re connecting to and select Save.
![Putty Configuration window](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=7a4f7979-bed3-41b6-a4ca-ede4931c8c4a.png)
For a quick way to load these settings and then connect, you can double-click on the saved session in the future. Alternatively, click on the saved entry, choose Load, then Open.
Once the terminal session starts, you will be able to launch programs from the command line. Xming will distinguish remote programs by putting its icon on any windows that open through X forwarding.
![](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=909ae864-9f10-402a-a922-4b9020e1b2ef.png)
From macOS
X11 is no longer included with Mac, but X11 server and client libraries are available from the XQuartz project. Download and install the latest XQuartz release.
From the XQuartz terminal window, run the following: ssh -X username@computername
![XQuartz terminal window with command line](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=c28e0771-85e7-4428-8e5f-d18a55518d5f.png)
Once connected, you can run any program that utilizes X forwarding.
Here is an example of what running xclock looks like from a Mac:
![xclock](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=8a86a929-813d-4480-bc2b-35c070f8885a.png)
Programs can be quit by closing the window or by pressing CTRL + C in the XQuartz terminal
X Forwarding Between Two Macs
If you would like to utilize X11 between two macOS computers, XQuartz must be installed on both and the following etc/ssh/sshd_config settings must be configured on the Mac from which you wish to enable X11 forwarding.
Please also note that macOS has very limited support for acting as a host for X forwarding programs. Many programs by Apple or those exclusive to macOS may not have support to run in this manner.
Procedure
- From the Terminal app, make sure you su username-adm
![terminal window su username-adm](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=de08c686-0d55-4e64-89b3-9d98cc4a8ecb.png)
-
Run sudo vim /etc/ssh/sshd_config
![terminal window command line](https://servicedesk.mtu.edu/TDPortal/Images/Viewer?fileName=89b43f9c-8136-498e-8725-99400b390247.png)
-
Add these two lines to the file:
X11Forwarding yes
X11DisplayOffset 10
-
Save and quit the file. You may need to restart sshd by performing the following commands:
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist