6

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?

3 Answers 3

2

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.

1
  • 1
    See my answer. OpenSSH does support the runtime creation of port forwards. Apr 4, 2012 at 17:55
4

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.

1
  • 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, 2012 at 18:01
1

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.

1
  • Curses! Beat me by ten seconds! =)
    – Wesley
    Apr 4, 2012 at 17:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .