On Unix systems, windowing systems are an optional component. There are numerous window systems but the most prevalent, as I understand it, is X. It’s a networked client/server model, where the machine with the display and input devices is called the server, and the machine running windowed apps against this server is the client. This is backwards from how you typically think about clients and servers, i.e. servers are usually headless and clients are usually responsible for rendering data from servers and translating input.
I usually interact with my BSD machine from my Windows laptop using PuTTY. But running Emacs in a terminal window is sometimes hard on the eyes, it’s hard to get good fonts, color schemes, etc. I wanted to see if I could launch Emacs from PuTTY but have it render its UI over the X protocol on my Windows laptop. This was harder than I thought, and I didn’t find any step-by-step tutorial to help me troubleshoot, so here’s an account of what worked for me. Note that I started from a relatively clean install of FreeBSD 10.1, with only
sshd and some basic packages installed.
To prepare the BSD machine for acting as an X client, I had to install the
$ sudo pkg install xauth
The only visible result of this is the addition of the
DISPLAY environment variable in upcoming SSH sessions, set to its default
Now to set up the X server, i.e. my Windows laptop. First I installed Xming from SourceForge. I opted not to include any bundled PuTTY, as I already had it installed.
Then I configured the PuTTY connection to my BSD machine to do X11 forwarding, see screenshot below:
(don’t forget to save that setting on the connection in question.)
I installed the
xterm package on my BSD machine to have a simple app to test this setup. Here’s what the workflow looks like to run an X application on the BSD box showing its UI on the Windows side:
- Connect with PuTTY, using a connection with X11 forwarding
- Start Xming on the Windows box (this is the X server responsible for rendering the UI of the remote app)
- Start the application from the shell, e.g.
After a short delay, the
xterm application should show a window on the Windows desktop. Note that the app is executing on the BSD box, but showing its UI over the networked X11 protocol via Xming on Windows.
Now I just need to figure out how to set up nicer fonts and coloring in this environment.