Tag Archives: MobaXterm X11-forwarding

How to Enable X11-forwarding with MobaXterm

Linux system also has a graphical interface. Its way is different from Windows, called X Window, using the X11 protocol. The X in X11 refers to the X protocol; the 11 refers to the 11th version using the X protocol.
image.png
The schematic is above. So when we use the client to log in to a server, when we display the image interface, which is the X client and which is the X server?
The answer is that the client is the X server. For example, we use MobaXterm to log in to the server. MobaXterm is the X Server, and the Linux server is the X Client.
image.png
When I log in to my ECS, this graphical interface is unavailable at first: X11-forwarding : ✘ (disabled or not supported by server).
That is to say, when I run a program to display a graphical interface on the server, the result will fail, like the following:

[root@ecs-d589 ~]# xclock
Error: Can't open display:

So what to do? In fact, it can be operated in two places, one is to install the X authentication package, and the other is to open ssh forwarding.
The command to install the X authentication package is: yum install xorg-x11-xauth
its description is as follows:
Summary : X.Org X11 X authority utilities
Description : xauth is used to edit and display the authorization information used in connecting to an X server.
The way to open ssh forwarding is to edit /etc/ssh/sshd_config:

#AllowAgentForwarding yes
AllowTcpForwarding yes   #enable
#GatewayPorts no
X11Forwarding yes      #default is enable
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes

Then restart the sshd service:
[root@ecs-d589 ~]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service

And log out and log back in.
image.png
It can be seen that the first prompt X11-Forwarding is that it has been opened normally, and then we run a simple program xclock on the server, and the clock graphical interface of the program can be correctly displayed on the screen.
In addition, there is an additional error message after logging in as follows, we can ignore it for the time being.
/usr/bin/xauth: file /root/.Xauthority does not exist