I have two computers in my life: a desktop at home, where my code lives; and a laptop which I mostly use to ssh into the desktop. The desktop runs Debian. Until recently, the laptop ran Windows, and I used Ubuntu in WSL to ssh into the desktop.
I switch my laptop to NixOS,
and suddenly, my ssh -X
sessions become glacially slow.
It's worse when I'm on a different network from the desktop,
but even when I'm on the local network,
it's so slow that Gnome considers the program unresponsive.
First things first, some sanity checks. I compile the latest stable version of Emacs from source on my laptop and on the desktop.
Next, I use xtruss to examine the X11 messages being sent between Emacs and the X server, both on my laptop and when X forwarding to the desktop. I examine the differences between them using ediff.
The earliest significant difference between these outputs is the lack of some extension support. xkeyboard is apparently not available when X forwarding. And there's some "RENDER" extension that's not working?
Well that looks like the kind of problem that could make things slow. Is there anything about X forwarding that might cause extensions to be disabled? Let's read the ssh man page.
Remember kids: always read the man page.
So, to recap,
ssh -X
, the thing everyone does,
by default, disables some important X11 extensions for security reasons.
-Y
instead.
ssh -X
basically unusable,
just makes it an alias for ssh -Y
instead.
-X
because I'm always sshing from a Debian machine
and don't even know -Y
exists.
-Y
instead of -X
,
or add ForwardX11Trusted=yes
as a line in your ~/.ssh/config
Even reading the ssh man page,
it might not be obvious that -Y
is the solution.
The man page makes no mention of slowness,
and only the Debian version of the page even mentions that (extremely common) problems can be caused by using -X
instead of -Y
(I happened to open that page when I was on the desktop,
which was very helpful).
It was obvious to me,
but that's only because I'd spent an hour intercepting and examining the X11 messages.
-X
enables X forwarding.
-x
disables X forwarding.
-Y
enables trusted X forwarding.
-y
sends log information using syslog(3) instead of stderr.