XPRA IS SCREEN for X11, as xpra describes itself on its page.

xpra allows to run X11 applications on a remote machine and benefit from the detach/attach workflow known from e.g. screen and tmux.

I coincidentally discovered xpra today, when google’ing on how to setup copy to clipboard in tmux (this is a good guide). Generally copy/paste and clipboard interaction is clunky in tmux (especially when having multiple panes), so I contemplated that xpra could be used in conjunction with terminator, to have a nice remote terminal experience with copy/paste that just works.

L2» apt install xpra

Upon starting it, I was hit by some issues getting ssh authentication working

L2» xpra start ssh://skv@: --exit-with-children --start=terminator
2021-07-01 08:33:07,487 loaded RSA private key from '/home/skv/.ssh/id_rsa'
2021-07-01 08:33:07,565 Authentication (publickey) failed.
2021-07-01 08:33:07,565 SSH authentication using key '/home/skv/.ssh/id_rsa' failed:
2021-07-01 08:33:07,566  Authentication failed.
2021-07-01 08:33:07,856 SSH password authentication failed:
2021-07-01 08:33:07,856  Bad authentication type; allowed types: ['publickey', 'password']
xpra initialization error:
 SSH Authentication on  failed

I suspect this is because the user on both the local and remote machine is both called ‘skv’, but are not the same and have different ssh keys.
In the xpra man page I found that the option --ssh can be used to set a custom ssh command. So I forced password mode (which I normally use towards that machine)

L2» xpra start --ssh="ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no" ssh://skv@: --exit-with-children --start=terminator

After running the above command, the remote terminal with terminator opens ans any other local terminal

The above runs a “single shot” command. After exit the process disappears. Often when running serial logging from an attached embedded device, we want the logging session continue to run, after we exit the session. For this start a xpra instance on the remote machine

# Login to remote using ssh
L2» sshpass -p  ssh -o ForwardX11=yes -Y skv@ -p 

# Start xpra server with a program
remote❯ xpra start --start=terminator
Entering daemon mode; any further errors will be reported to:
  /run/user/1000/xpra/S2213592.log

Actual display used: :3
Actual log file name is now: /run/user/1000/xpra/:3.log

# Check that its running
remote❯ xpra list
Found the following xpra sessions:
/run/user/1000/xpra:
        LIVE session at :3
/home/skv/.xpra:
        LIVE session at :3

Now on the local machine, attach to the remote process

L2» xpra attach --ssh="ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no" ssh://skv@:

Detach when wanting the process to live on, on the remote machine only. Work can be continued by a later attach action

skv@L3 ~ 
L2» xpra detach --ssh="ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no" ssh://skv@: 

Copy/Paste

So how does the copy/paste experience compare with clunky tmux?…

Quite good actually. No different than if it was on your local machine. Pretty sweet

Categories: LinuxSoftware