Why does ssh X forwarding timeout after a while

sshx11-forwarding

So I have a mac at work which I like to ssh into my linux box with something like this:

$ ssh -Xt user@mylinux

I can login and start any X11 apps on my linux box no problem. But after 15 minutes or so, I come back to a session (ssh is still running and connected) and I get:

$ xterm 
xterm Xt error: Can't open display: localhost:12.0

I've tried using -o "TCPKeepAlive yes" or -o "ServerAliveInterval 30", but still get the same behavior.

Is there something in ssh or on the Mac or my linux sshd conf that kills X-forwarding after a period of inactivity?

Best Answer

The default ForwardX11Timeout is 20 minutes for ssh -X, but you can set it to something large (e.g. 7d for 7 days) in .ssh/config

"Trusted" X11 forwarding via ssh -Y actually enables potentially nasty things like keystroke monitoring and screen grabs.

Related Question