Don't disable ipv6...

…if you want X11 Forwarding to work over ssh!

I spent hours trying to figure out why in the blue blazes I couldn’t get X11 Forwarding to work. Normally, I never really cared - if I want CLI access, I use ssh. If I want GUI access, I use VNC or RDP. But for one reason or another, I thought “hey, it would be really neat if I could run just one remote linux gui app on my local desktop, rather than an entire remote desktop”. So, I started working at this.

MobaXterm has this neat little feature during the initial connection where it gives you a formatted banner about some of the details of the ssh connection - X11 Forwarding, compression, etc. I’d noticed in the past that most of my devices showed X11 Forwarding as ‘enabled’, with a green check mark. Not all of them, though. Every once in a while, one showed ‘disabled’ with a red X. Again, I never really paid any attention to that, because well… I didn’t use it. Now, though…

At first I thought it was a Raspberry Pi problem… then maybe a DietPi problem… then maybe a MobaXterm problem. Thing is, I saw lots of recommendations for MobaXterm for exactly this use - it comes with built-in Xwindows support, no need for another external program like with PuTTY / Xming. And I saw more than a few examples of people connecting with RPi’s. Yes, I had ‘X11 Forwarding’ uncommented in /etc/ssh/sshd_config, and yes, it was toggled to ‘yes’, and yes, it was the sshd_config file, not the ssh_config file, and yes, I had xauth installed. WTF?!?

After giving up on reading yet another tutorial, because all they ever show is what happens when everything works right… I was wading thru page after page of search results on DDG. Finally stumbled across a thread on Unix StackExchange, which linked to a ten year old thread on that mentioned a bug in openssh: disabling ipv6 breaks X11 forwarding in ssh.

Part of me couldn’t believe that this would possibly turn out to be the fix. Ten year old bug, and still silently breaking things? Naw…

Yep. During initial configuration of this particular RPi, I’d turned off ipv6 because hey, I don’t need that crap for my home network! Turns out that was probably why I sometimes saw MobaXterm show X11 forwarding as ‘disabled’, and sometimes not, as I nuked and reloaded various configurations testing one thing or another.

Fired up dietpi-launcher, got into the dietpi-config tool and turned back on ipv6 networking, re-enabled ‘prefer ipv4’, saved and rebooted. Voila, I now had X11 forwarding!!! And yes, it works :wink:

thx for sharing. good to keep that in mind.

The alternative is to start OpenSSH with the IPv4 flag, if I get it right?

G_CONFIG_INJECT 'AddressFamily[[:blank:]]' 'AddressFamily inet' /etc/ssh/sshd_config