documentation:ssh_docker_display

Display over SSH and inside a docker

Prerequisities:

  • /etc/ssh/sshd_config contains X11UseLocalhost no
  • Assuming the use of ROS containers repo on git.cs.lth.se

Connect with -X or -Y (trusted) over SSH to the robot, using robotmind2 as an example here.

Run the first command to get your DISPLAY, it should be non-empty as otherwise the SSH connected with X11 forwarding failed.

$ echo $DISPLAY
robotmind2:12.0

In order for the container to connect it will also need a secret cookie that changes with each connection.

$ xauth list
robotmind2/unix:12  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef
robotmind2/unix:11  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef
robotmind2/unix:10  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef
robotmind2:10  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef
robotmind2:11  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef
robotmind2:12  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef

The cookie is different in the real world, but in hex. Copy the relevant one based on your $DISPLAY

Then go inside your container:

$ export DISPLAY=robotmind2:12.0
$ xauth add robotmind2:12  MIT-MAGIC-COOKIE-1  0123456789abcdef0123456789abcdef

Change names as needed, xauth add should have the matching cookie for your $DISPLAY.

Now X11 forwarding should work over ssh inside a docker container.

  • documentation/ssh_docker_display.txt
  • Last modified: 2024/04/05 08:37
  • by marcusk