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?
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?
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.
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.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.