I just spent a few hours trying to get X11 forwarding over SSH working in one of my jails. I was using the same configuration as the host machine, but there's more to it than that. Here's what needs doing:
-
Install
xauth
withpkg install xauth
-
Add the following line to
/etc/hosts
192.168.1.204 myhostname
With the IP address and hostname you gave the jail. When you ssh in with X11 forwarding, it will try to resolve the machine's hostname. This tells it to use the IP address of the jail.
-
Make sure these three lines exist in
/etc/ssh/sshd_config
AllowTcpForwarding yes X11Forwarding yes X11UseLocalhost no
The last line is important because jails don't get their own network stack, so localhost will point to the actual host and not the jail.
-
Restart SSH with
service sshd_restart
Now everything should be good to go.