1

I've been using X11 forwarding to forward clipboard contents from remote servers.

When I tried to use X11 forwarding from one GUI linux computer to another, I noticed something peculiar. Let's say that machine A sshs into machine B.

I can issue the following command on any machine to check its clipboard contents

xclip -selection clipboard -o

I see the same clipboard contents when I issue it on A and on the ssh prompt connected from A to B.

However, if I issue it on machine B's GUI session, then I see different contents!

Does this mean that machine B has two X11 sessions? One for the GUI, and one created when I ssh'd into it via A?

Since on linux everything is a file, where do files for these respective sessions live?

5

When you forward an X11 connection, you give the remote system access to your local X11 session (through SSH). Thus, when you connect to B from A, with X11 forwarding enabled, the programs you run in that SSH session are connected to your X11 session on A. This explains why xclip shows the same contents on A and in the SSH session from A to B.

The X11 session on B is separate, and isn’t connected to A or your SSH session.

There are two X11 sessions, but not on B: one on A, one on B.

X11 sessions “live” in the X11 server, they’re not stored in files.

2
  • This makes sense. However, shouldn't it be the case that A's X11 session lives on A but is being "exposed" to B through some files (or socket file)? Also your answer prompts an additional question: is it possible for a machine to have multiple X11 sessions of their own? Jan 4 at 9:07
  • With SSH X11 forwarding, it’s exposed over TCP; on B, look for a process listening on port 6010 (or 6000 + whatever your DISPLAY is set to). A single machine can have multiple X11 sessions: multiple X11 servers can run on a single machine. Jan 4 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.