Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm connecting to a server via SSH and sometimes it freezes for some minutes, then throws the 'pipe broken' message and returns to my console. When I log in again and do a who, I still see that the user is logged in, and these keep piling up. How do I kill them? I'm logging in as root every time.

share|improve this question
    
I strongly recommend "screen" to you. It is made exactly for instable connections and you will never miss any output again. In case your ssh connection terminates (for any reason whatsoever) you simply relogin and do "screen -r". BTW: a very cool clone is "byobu". –  math Mar 18 '12 at 18:52

1 Answer 1

up vote 3 down vote accepted

In short, just kill the PID of the corresponding SSH session:

Find logged in users and TTYs:

w

05:04:54 up 14 days, 10:32,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT
myuser   pts/0    xxx.xxx.xxx.xxx   04:48    0.00s  0.03s  0.01s sshd: myuser
myuser   pts/1    xxx.xxx.xxx.xxx   05:04    2.00s  0.00s  0.00s -bash

Get matching PID (in this case, matching pts/1):

ps -ef | grep ssh.*pts/1

myuser   11575 11573  0 05:04 ?        00:00:00 sshd: myuser@pts/1
root     11670 11100  0 05:06 pts/0    00:00:00 grep ssh.*pts/1

Terminate process (in this case 11575, above):

sudo kill 11575
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.