How to make X.org listen to remote connections on port 6000?

Solution 1:

(Here follows an almost verbatim copy of a self-answer from an identical question on serverfault which I'd forgotten about; askubuntu wasn't yet created).

Based on information found in this page about enabling XDCMP and the file /etc/gdm/gdm.schemas, I managed to create a /etc/gdm/custom.conf file:

# /etc/gdm/custom.conf
[xdmcp]

[chooser]

[security]
DisallowTCP=false

[debug]

Take care with letter case: it won't work, if you write "disallowTCP=false"... I also changed the /etc/X11/xinit/xserverrc file to:

exec /usr/bin/X11/X

i.e. I removed the -nolisten tcp options to the X executable. I don't know if I needed to. You might want to try avoiding this edit.

If you only change the xserverrc file, X will nevertheless start with "-nolisten TCP".

After that, all that is needed is a restart of the gdm process:

sudo service gdm restart

You can verify the success as:

tzot@tzot-laptop:/etc/X11
$ netstat -an | grep -F 6000
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN
tcp6       0      0 :::6000                 :::*                    LISTEN

Update

After an upgrade to 12.04, I had the same issue. This time, the culprit is the lightdm that the system uses. The file that needs to be updated is /etc/lightdm/lightdm.conf and the required addition is a xserver-allow-tcp=true in the [SeatDefaults] section.

And afterwards, I also found that answer. :)

Synopsis

So, in 10.10 this still works: create /etc/gdm/custom.conf with contents as specified above and restart gdm.

Solution 2:

This answer is related to Kubuntu 17.04 and 20.04 and I added it, because none of the other answers (related to gdm or lightdm) helped me. In my case sddm was running. To check this, run for instance

ps -eal | grep sddm

If it is is running, processes sddm and sddm-helper are shown. In this case add a configuration file /etc/sddm.conf with content

[X11]
ServerArguments=-listen tcp

for 20.04 or

[XDisplay]
ServerArguments=-listen tcp

for 17.04. After creation of this file reboot your system (may be a sddm restart is sufficient). As a consequence

ps ax | grep sddm 

shows the desired Xorg option -listen tcp and the X Server is ready for incoming connections (don't forget to add the remote host with xhost).

Solution 3:

Ubuntu 18.04 running as lubuntu 18.04 with lightdm 1.26.0, this is what I had to do (only took me a couple weeks to figure it all out). You have to create both /etc/lightdm/lightdm.conf and /etc/lightdm.conf.d/50-xserver-command.conf as follows:

sudo vi /etc/lightdm/lightdm.conf:

[Seat:*]

xserver-allow-tcp=true
xserver-command=X -listen tcp

sudo vi /etc/lightdm/lightdm.conf.d/50-xserver-command.conf:

[Seat:*]

xserver-command=X -core -listen tcp

This will cause lightdm to run Xorg with the following command line:

Xorg -listen tcp :0 -seat seat0 -auth /var/run/lightdm/root/:0 -listen tcp vt7  
   -novtswitch

This has "-listen tcp" twice, but it doesn't hurt anything. If you don't have both files, one of the Xorg options will be "-nolisten tcp" which overrides the other "-listen tcp". I finally found the clues to this here.

Then add: xhost + to your .bashrc

Restart and check that Xorg is now listening on port 6000:

$ netstat -nal | grep 6000
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN     
tcp6       0      0 :::6000                 :::*                    LISTEN     

Enjoy...

Solution 4:

As of Ubuntu 18.04, I looked at the running processes and figured out the display manager being used is gdm3:

$ ps ax|grep dm
 1515 ?        Ssl    0:00 /usr/sbin/gdm3

Then I edited /etc/gdm3/custom.conf and added a line:

[security]
DisallowTCP=false

As mentioned, opening up port 6000 is not secure. However, I'm using this only at home network and the port is further secured by iptables to open up only to my primary laptop, it should be ok.