-
Notifications
You must be signed in to change notification settings - Fork 379
Remote access with SSH
mviereck edited this page Sep 20, 2018
·
12 revisions
You can run x11docker on remote servers with ssh -X
like a regular X application. Example:
# Replace localhost with address of your desired server
ssh -X localhost -- x11docker x11docker/lxde lxterminal
If your server has Xephyr
installed, you can run desktop environments like a VNC session:
ssh -X localhost -- x11docker --desktop x11docker/lxde
SSH setup with xpra allows detaching and reattaching to a remote session.
Example for an SSH setup with xpra:
- Server setup:
# run invisible Xvfb X server with display number :30.
# catch X environment with 'read < <(...)' construct.
# docker container runs on invisible new display.
read Xenv < <(x11docker --xvfb --display=30 --showenv x11docker/lxde pcmanfm)
# Output of new X environment, just for info
echo $Xenv
# You can drop `--display=30` in command above if you provide DISPLAY
# from this output to following xpra commands instead of :30
# start xpra server with new environment variables.
# (replace "start" with "start-desktop" to forward a desktop environment)
env $Xenv xpra start :30 --use-display --start-via-proxy=no
- Client setup:
# Attach xpra client over SSH to xpra server
xpra attach ssh:$HOSTNAME:30 # replace $HOSTNAME with IP or host name of ssh server
You can detach the SSH connection and attach later again without terminating the container application:
xpra detach ssh:$HOSTNAME:30
You can stop xpra server without terminating x11docker:
xpra stop ssh:$HOSTNAME:30
A script entirely executed on client. (It will ask three times for ssh password, may be solved more nicely).
#! /bin/bash
HOSTNAME=localhost # Change to desired server address
IMAGECOMMAND="x11docker/lxde lxterminal" # Change to desired image name and command
# Runs x11docker on remote server. Reads new X environment variables from its output.
read Xenv < <(ssh -f $HOSTNAME -- x11docker --xvfb --showenv $IMAGECOMMAND)
# extracts display from new X environment
Newdisplay=$(sh -c "export $Xenv ; echo \$DISPLAY")
# start remote xpra server
ssh $HOSTNAME -- env $Xenv xpra start $Newdisplay --use-display --start-via-proxy=no
# start local xpra client
xpra attach ssh:$HOSTNAME$Newdisplay
- Warning: don't try this on localhost due to an xpra memory bug in xpra versions <v2.4.
- If your client does have a big display resolution or a multimonitor setup, xpra may scale up the size of forwarded windows. Check output of
xrandr | grep current
or xpra client output for your client display resolution. It may be e.g.2084x768
. Add--size 2048x768
tox11docker --xvfb [...]
command to get a matching server display size.