X problems across OpenSSH

I had difficulties using emacs from a Debian box, via a FreeBSD-based X server. After a short while, it would die with the following error:

  X protocol error: BadWindow (invalid Window parameter) on protocol request 38

This turned out to be because ForwardX11Trusted is turned off, by default, in OpenSSH 3.8 and later. This causes problems with X clients (such as emacs) which need full access to the X server.

To fix, either invoke ssh on the client with the -Y option, or set ForwardX11Trusted in the /etc/ssh/ssh_config or /~/.ssh/config files:

ForwardX11Trusted yes

This is documented in the OpenSSH FAQ, which no longer exists on the OpenSSH.com site.