One way is to use the ssh escape character. By default this is "~", but it can be set manually with -e
option when invoking ssh or via EscapeChar
in your ssh config. To kill the hung session this will often work:
~.
As pointed out by Gilles this is only recognized immediately after hitting Enter.
If you are using a server-in-the-middle to interconnect two systems, chances are at least one of the lines is rather slow. In that case VNC is likely to give you better performance, since you can tune the bandwidth/performance requiremens/quality ratios better (this is actually valid for most setups, unless you are on a reliable 100Mbit+ network).
I personally like x11vnc
, which connects to a running X server and forwards the inputs/output over the VNC protocol (this can be done as soon the X server is running, so you can interact even with a display manager). The X server in question can be both a regular one (which outputs to a real display) or a framebuffer based one like Xvfb
. You can then use any VNC client to connect to the exported X server. And of course you probably want to tunnel the transmissionn through ssh
or stunnel
. The man page of x11vnc
is quite exhaustive and even has a frequently used command line example at the beginning.
Ths also allows you to remotely connect to a running session to help somebody solve a problem remotely. As an important bonus, since just the inputs and output are forwarded rather than the X protocol itself, network disconnects will just interrupt the session, but all of the programs remain running, which is not the case of X through SSH.
If for some reason you really want to tunnel X11 through SSH, you must ensure that the DISPLAY
environment variable is set up properly by ssh
. Without it you can't proceed, because the applications won't know which server to connect to. Check whether the X11Forwarding
directive is set to yes
in your sshd
configuration.
Last but not the least, you probably don't want to run startkde4
(or any other X session for that matter) over SSH - the network load will likely be quite heavy - VNC will serve you better again.
Best Answer
Switch to a second terminal, for example tty2: CtrlAlt-F2, login and start a new X session on an available display:
Now ssh to the other machine, enabling X forwarding (or trusted X forwarding with
-Y
):Once logged in, start a new gnome-session:
You can also pass
gnome-session
as a command tossh
.