Why does the ssh daemon set up two processes?

This is a discussion on Why does the ssh daemon set up two processes? within the Tech Board forums, part of the Community Boards category; When I ssh from my home machine to a remote machine, I see the following % ps waux | grep ...

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    Why does the ssh daemon set up two processes?

    When I ssh from my home machine to a remote machine, I see the following

    % ps waux | grep cd
    root 97334 5.6 0.3 6272 2968 ?? Ss 8:10PM 0:01.03 sshd: cd [priv] (sshd)
    cd 97337 0.9 0.2 3736 2468 p5 SNs 8:10PM 0:00.14 -zsh (zsh)
    cd 97336 0.0 0.3 6260 2984 ?? SN 8:10PM 0:00.02 sshd: cd@ttyp5 (sshd)
    Why do I have two instances of ssh? Ie one for root and one for my username cd?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    One is the actual daemon that runs the ssh base-protocol. But since that HAS to run as root, you don't want that process to actually perform your commands on the other end, so it forks and resets the user-id to your personal user-id [it actually will do that even if you are logged in as root, since it still wants to run all commands for one session in one process, rather than having a bunch of commands come into the same process from differens sessions, that would be hard to track - for example, you would have to deal with multiple "current working directory" for two different sessions - messy].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Okay, that makes sense. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 01-18-2008, 03:06 AM
  2. Replies: 4
    Last Post: 01-13-2008, 01:14 AM
  3. Replies: 7
    Last Post: 08-19-2007, 08:10 AM
  4. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21