Server Fault is a question and answer site for system and network administrators. 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

I know I can connect to a host and use window apps via running ssh -X <host>.

But what if I'm already connected via normal ssh e.g., ssh <host>.

Is there a way to turn X forwarding on without having to reconnect?

share|improve this question
up vote 2 down vote accepted

When an SSH connection is up, it's up. You need to tear it down and recreate an SSH connection with the options that you want (with the exception of port forwarding as mentioned in Mark Wagner's answer). There is a feature of OpenSSH 4.0+ that uses the ControlMaster option for new SSH commands to re-use an existing connection, but that's not exactly what you want.

share|improve this answer
See my answer. OpenSSH does support the runtime creation of port forwards. – Mark Wagner Apr 4 '12 at 17:55

Not easily. As of OpenSSH 5.1 the ~C escape commandline supports runtime creation of dynamic (-D) port forwards. If your local X server is listening on a TCP socket you could create a port forward to it. Nowadays most X servers don't. Supposing it is, though, you'd then need to set up the xauth data and set the DISPLAY environment variable.

Internally, OpenSSH forwards to your X server's unix domain socket and automatically handles the xauth data and setting DISPLAY.

share|improve this answer
Fascinating - I didn't know that anything could be changed on an existing SSH tunnel. So you kinda can forward X - but only if you've laid the groundwork ahead of time. – Wesley Apr 4 '12 at 18:01

No dynamic change of an existing connection is supported, because the forwarding is set up when the connection established, so you have to reconnect in order to enable/disable this.

share|improve this answer
Curses! Beat me by ten seconds! =) – Wesley Apr 4 '12 at 17:43

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.