Find the answer to your Linux question:
Results 1 to 6 of 6
Hello Occasionnally, a remote host can have a problem while connected with SSH, and leave a dead connection: Code: # who USER TTY IDLE TIME HOST root pts/0 00:00 Mar ...
  1. #1
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127

    Question [who] Removing dead connections?

    Hello

    Occasionnally, a remote host can have a problem while connected with SSH, and leave a dead connection:

    Code:
    # who
    USER       TTY      IDLE      TIME           HOST
    root       pts/0    00:00     Mar 10 23:35:1 somehost.acme.com
    root       pts/1    00:14     Mar 11 00:25:2 somehost.acme.com
    root       pts/2    ?         Mar 10 02:34:3 somehost.acme.com
    root       pts/3    ?         Mar 10 18:56:4 somehost.acme.com
    root       pts/4    ?         Feb 21 17:51:0 somehost.acme.com
    root       pts/5    ?         Feb 26 00:31:2 somehost.acme.com
    How can I remove those dead connections?

    Thank you.

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Identify the PIDs:
    ps -ef | egrep 'PID|sshd'

    then kill the PIDs associated with ttys.

  3. #3
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127
    Thanks, but dead connections aren't listed when I run the above, only the active connections:

    Code:
    # ps | egrep 'PID|sshd'
      PID  Uid        VSZ Stat Command
     1482 root       4412 S   /usr/sbin/sshd: root@pts/0
     1502 root       4472 S   /usr/sbin/sshd: root@pts/1
     1771 root       1780 S   /usr/sbin/sshd
     1790 root       1068 S   egrep PID|sshd

  4. #4
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Use the -ef options with ps.

    I'm not sure why grep'ing for sshd didn't show the old connections. Pipe all processes to less and see if you can locate the PIDs that way.

  5. #5
    Linux Newbie
    Join Date
    Nov 2007
    Posts
    127
    Sorry, but I forgot to mention it's a small Linux distro running of a Compact Flash card, and "ps" is from BusyBox, hence less features than the full-fledged version.

    Dead SSH sessions aren't listed. I'll see if I can find how to remove them from "who".

    Thanks.

  6. #6
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    In that case, you might plan for an appropriate time to restart sshd. I'd expect that to clean up what you're seeing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...