After the video card in my desktop computer fried last week for some reasons unknown to me, I moved to use my laptop as the basis of my daily work environment for a few days. And now that my desktop is back in service, I’m thinking to move to a laptop-only mode. But this move is pending some hardware complements (e.g. a port replicator), and I decided that I should start using my laptop system right now rather than later; I’d rather not plug all my existing devices in the laptop since I would have to unplug them too frequently, so I’ve decided to transform at least temporarily my desktop in a simple X Terminal.
I toyed with the idea of using a solution based on VNC, which allows one to share a unique X Session on two or more computers, especially as Gnome includes a server (vino) easily configurable; but my tests with various clients (xtightvncserver, xvncserver, svncviewer) were quite inconclusive, the resulting experience being always very sluggish (limited by CPU, I think, which on a 1.60 GHz computer would be disappointing), and sometimes buggy (e.g. key press being repeated too many times). I probably should investigate further whether this is to be expected or due to some failure on my part…
Meanwhile, I decided to took the traditional X-over-the-network approach ; the default and well-deployed solution is to use XDMCP, which is really easy to set up when using Gnome login manager (gdm); the only problem is that XDMCP is really insecure (transmitting passwords on the clear), and although this would be mainly to run on my local wired network, I don’t want to rely on security through obscurity.
Unfortunately, it appears one cannot run XDMCP through ssh, since it relies on UDP traffic which apparently ssh can’t tunnel. So securing XDMCP is not directly easy.
I then found about sdm which basically does what I want: it acts as a graphical login manager, which instead of running a traditional X-session starts an ssh connection to your target host and launch your traditional X session manager there.
The only problem with that solution is that I don’t want to rely on another login manager but gdm, since it’s well integrated with Gnome; so instead, I quickly reimplemented the equivalent solution for GDM, which proved to be quite easy: I only had to add (in Debian) the two following files to get a new session type available from the GDM session menu under the name “SSH”.
The most important file is a simple shell script that will act as the X session manager: it asks graphically which host to connect to, asks the passphrase, connects through ssh and invokes the local x-session-manager. I placed it under /usr/local/bin/ssh-session:
#!/bin/bash TARGETHOST=`zenity --title "Host to connect to" --entry --text "Enter the name of the host you want to log in to"` #@@@ should probably get a user name too; I don't need it so didn't set it up that way #@@@ should it do an ssh-add so the user doesn't have to enter its passphrase again? SSH_ASKPASS=/etc/alternative/ssh-askpass /usr/bin/ssh -A -X -T -n "$TARGETHOST" /usr/bin/x-session-manager
(Ideally, the zenity call should include a list of servers, either taken from .ssh/known_hosts, or from a zeroconf lists of local servers that provide an ssh connection; too bad Zeroconf is still so little implemented on linux, but hopefully Avahi should fix that in the near future)
The other file is the one responsible to linking that session manager from GDM; it’s a simple .desktop file, which I placed at
[Desktop Entry] Encoding=UTF-8 Name=SSH Comment=This session logs you into a remote host using ssh Exec=/usr/local/bin/ssh-session Type=Application
(Given that it relies on the existing Debian conventions, this should also work to start a remote KDE session through kdm.)
So now I can connect from my desktop directly into my laptop system, and the resulting experience is impressively good with a 100Mbs ethernet connection (on the 11 Mbs wireless connection, the result is much less pleasing) ; it doesn’t seem to take much CPU at all on the laptop either.