6

I am very confused about the field X11DisplayOffset in sshd_config

Offset mean a position shift from the correct as lubuntu - Display offset. See image - Ask Ubuntu

However, when do ssh -X user@host to open 'firefox' on a remote desktop,
The Browser display correctly without offset.

What does X11DisplayOffset do?

Alice
  • 1,710

2 Answers2

10

X11DisplayOffset does not refer to an offset within the geometry of the display - it relates to the identification of which display clients started over the SSH connection should use in order not to interfere with local displays. From man sshd_config:

 X11DisplayOffset
         Specifies the first display number available for sshd(8)'s X11
         forwarding.  This prevents sshd from interfering with real X11
         servers.  The default is 10.

The architecture of X Windows allows for an X server to manage multiple displays. Typically on a standalone workstation with a single local user, you only have to deal with a single display - usually numbered 0 and often referred to as :0, for example in environment variable assignments like DISPLAY=:0. But on servers that may be running several X sessions (users remoting in via VNC for example, or separate X sessions on different virtual terminals) there may be multiple displays, labelled :1, :2, and so on.

When X11 forwarding over SSH is added to the mix, that adds a requirement for additional unique display numbers (so that X clients tunneled over the SSH connection get directed to the correct remote display server). In order to avoid conflicts with local displays, an offset is added to the display numbering scheme so that the remote displays are numbered :10, :11, :12, ...

steeldriver
  • 136,215
  • 21
  • 243
  • 336
6

The directive X11DisplayOffset is related to the $DISPLAY environment variable. From man sshd_config:

X11DisplayOffset
             Specifies the first display number available for sshd(8)'s X11 forwarding.  
             This prevents sshd from interfering with real X11 servers. The default is 10.

So, with the default settings, when you are using the -X option in your ssh command to the $DISPLAY envvar will be assigned value as follow (note without -X or -Y the variable will be unset):

$ echo $DISPLAY
localhost:10.0

where:

  • localhost (hostname) is the name of the computer where the X server runs. An omitted hostname means the localhost.

  • 10 (D) is a sequence number. It can be varied if there are multiple displays connected to one computer.

  • 0 (S) is the screen number. A display can actually have multiple screens.

pa4080
  • 29,831