Skip to content

Cannot use SSH X11 forwarding inside container #554

@eyespore

Description

@eyespore

Hi! first of all thanks for the great project.

I encountered a problem when trying to run openssh-server inside a container started with x11docker, and I want to confirm whether this behavior is expected, or whether x11docker can provide an option to support SSH X11 forwarding correctly.

1.Steps to Reproduce

1. Build a minimal test image containing OpenSSH server + Xterm

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y openssh-server xterm xauth
docker build -t ssh-x11-test .

This is a minimal environment intended only for verifying whether SSH X11 forwarding works inside an x11docker container.

2.Run the image using x11docker

Run the container with:

x11docker \
  --network=bridge \
  --name=tc \
  --runasroot='mkdir /run/sshd && /usr/sbin/sshd -D \&' \
  --runasroot="echo $(logname):1234 | chpasswd" \
  -- --privileged -p 8022:22 -- \
  ssh-x11-test

3. From the host, connect to the container via SSH with X11 forwarding

On the host machine, connect to the container using ssh with password 1234:

ssh -Y -p 8022 USER@CONTAINER_IP

once connected, you can verify environment with command:

echo $DISPLAY

Inside the SSH session, the DISPLAY variable is like DISPLAY=:120, However, This is the DISPLAY inherited from the x11docker-provided Xorg server inside the container, not the expected forwarded display such as DISPLAY=localhost:10.0

If I try to run Xterm with command xterm, The Xterm window appears inside the container’s Xorg display (the remote desktop), NOT on the external SSH client. Therefore, SSH X11 forwarding is not activated.

2.Closing Notes

I also performed the same tests using the x11docker/xfce image, and the result was identical — SSH X11 forwarding did not activate correctly, and the forwarded display was not created.

It is possible that I misunderstand how SSH X11 forwarding is expected to behave in an x11docker-managed environment, or that this behavior is intentional. If this setup is not supposed to work by design, please let me know.

I am aware that remote graphical access can be achieved through VNC or other methods; my intention here is simply to understand why SSH X11 forwarding does not function as expected inside containers started by x11docker.

Thanks for your time and for maintaining this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3rd party bugBug in a tool of someone else, not in x11docker

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions