Forum Moderators: bakedjake

Message Too Old, No Replies

Switching between terminals

Trying to regain control of lost SSH terminal

         

erikcw

8:10 pm on Aug 7, 2005 (gmt 0)

10+ Year Member



Hi all,

I was connected to my linux box via PUTTY, when all of a sudden I lost my internet connection. When I logged back into my system, I ran "w" and saw that my other terminal session was still active.


login as: ikesys
ikesys@host's password:
****************************************************************************
This computer system is for authorized users only. All activity is logged and
rugulary checked by systems personal. Individuals using this system without
authority or in excess of their authority are subject to having all their
services revoked. Any illegal services run by user or attempts to take down
this server or its services will be reported to local law enforcement, and
said user will be punished to the full extent of the law. Anyone using this
system consents to these terms.
*****************************************************************************
-bash-2.05b$ w
16:01:46 up 24 days, 10:08, 2 users, load average: 0.75, 0.62, 0.37
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ikesys pts/0 cpe-67-10-228-14 4:01pm 0.00s 0.04s 0.01s w
ikesys pts/1 cpe-67-10-228-14 Tue 7pm 2:07m 1.02s 0.05s /usr/sbin/sshd
-bash-2.05b$

I know when I am physically working on a linux machine I can use F-something (<Ctrl><Alt><F1>?) to switch between terminals. Is there an equivalent when working with Putty/SSH? I really need to get into TTY session pts/0 to access my work... When I press <Ctrl><Alt><F1> I just get a "~" (or F2 = [12~) on my shell...

Thanks!

mcavic

12:09 am on Aug 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once you lose your connection, there's no way to access that session. It'll terminate automatically after an hour or two. Or, you can use ps to find the process ID of that session's shell and kill it.

If you had a text editor open, the editor will usually save your changes into a backup file when it's killed.

erikcw

12:17 am on Aug 8, 2005 (gmt 0)

10+ Year Member



Is it possible to takeover the ps from the root account?

mcavic

12:31 am on Aug 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't access the session even with root, but you can kill it using root or your own account.

zCat

5:45 am on Aug 8, 2005 (gmt 0)

10+ Year Member



It won't help your current situation, but in order to protect yourself from the same kind of thing in future, try the program "screen" (should be in all good Linux distros).

Quick guide:

"screen" to start a session

Ctrl-A Ctrl-D to put the session into the background

"screen -r" to resume the last session
"screen -ls" to show what sessions are running

It works like this: connect to your server; execute "screen"; start something like "top"; forcibly kill the server connection (e.g. by closing the Putty window), login again, issue "screen -r" and you get your running "top" back.

erikcw

3:11 pm on Aug 8, 2005 (gmt 0)

10+ Year Member



wew - screen is a very cool tool! I will be using this in the future!

Thanks!