views:

479

answers:

2

Hi,

I have what is probably a very simple terminal related question. I'm running Ubuntu 8.10 Intrepid Ibex, using Gnome, and I often open a terminal-based ssh session only to have it dropped at some point later on. Once the session is dropped the terminal becomes unusable, obviously because the network connection has been dropped.

Is there a way to re-initialize the session, or even revert to a working local terminal?

Under Windows, using putty, when this happens I can right-click and select restart session, and do not need to open a new terminal, however under linux my lack of understanding on this subject has lead me to always close the defunct terminal, and restart a new one from scratch. I'd like to learn a new and useful trick if there's one out there.

Also, I found the following post which is worded very similarly to mine,

http://stackoverflow.com/questions/474967/automatically-or-more-easily- reconnect-to-a-screen-session-after-network-interr

however, as far as I can tell, this is a different topic.

+4  A: 

You want to use your SSH escape. By default it's '~', and ~. will terminate your connection.

The question you linked to is about screen, which is useful for resuming your remote session once you use the escape character to kill your local ssh process and reconnect.

anthony
thanks for the link and the synopsis. this seems to be just what I was looking for. also, although the default was set, I needed to un-comment it in my ssh setup, and run<pre><code>/etc/init.d/ssh restart</code></pre>
blackkettle
I like to use ~^Z, followed by `kill %`, but it comes out to about the same thing. If your network has poor connectivity, you may wish to make sure that your ssh configuration has keepalive enabled (periodically sending extra packets to verify that the connection is still available).
ephemient
+2  A: 

First use ~. to disconnect your ssh connection locally. This gets you back to a working local terminal. You could also you another terminal to kill the appropriate ssh command.

In order to keep your remote state you should use screen as previously suggested.

Douglas Leeder