Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Apr 1 '12 at 7:56

This question came from our site for professional and enthusiast programmers.

Is the X server still running? Do existing X apps get killed? – Ignacio Vazquez-Abrams Apr 1 '12 at 8:01
up vote 16 down vote accepted

Using -X, X11 forwarding is enabled in "Untrusted" mode, making use of various X11 security extensions, including a time-limited Xauth cookie.

Use -Y to enable "Trusted" mode for X11, which will enable complete access to your X11 server.

share|improve this answer
Great to know, thanks! – Larry Kyrala Apr 2 '12 at 11:20

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.

share|improve this answer
man ssh_config for this option documentation :) – drAlberT May 27 '13 at 16:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.