This concerns more on the installation of sshd1, but it is kind of
interesting, so I'll share.

sshd, when started as a standalone daemon, it binds to the port 22, so
starting another daemon with port 22 is not possible.
But when an incoming request from a client arrives sshd spwans another
process and hands the connection over to the newly created deamon so the
original daemon goes back to listening to the port 22.
But if the original daemon (the last one in the following ps output)

    root 12216 12088  1 10:35:36 ?        0:00 /usr/local/sbin/sshd
    root 12204 12088  1 10:35:20 ?        0:00 /usr/local/sbin/sshd
    root 12088     1  0 10:19:15 ?        0:03 /usr/local/sbin/sshd

dies for some reason, the other daemons survive and attach themselves to
process 1. I am kind of worried about starting and shutting down the
daemon at the startup script such as this:

case $1 in
        start)
                if [ -x $SSHD ]; then
                        if [ -r $SSHD_CONFIG ]; then
                                echo "Starting Secure Shell Daemon ...."
                                $SSHD
                        else
                                echo "$SSHD_CONFIG file not found."
                        fi
                fi
                ;;
        stop)
                if [ -r $SSHDPID ]; then
                        kill -KILL `cat $SSHDPID`
                else
                        echo "No process with ID $SSHDPID"
                fi
                ;;
        *)
                echo "Usage: /etc/init.d/sshd { start | stop }"
                ;;
esac

What would be the best way to start and shutdown sshd ensuring all the
daughter daemons are shut down. Should I go through the ps listing and
shut down one at a time before shutting down the "master daemon"? Or is it
safe to leave it alone for the system sending KILL signals to all the
processes?

Thanks,
Jaewan

Reply via email to