Andrew Hall writes:
> Hello,
> 
> This might be slightly off topic but here goes.  My issue is with
> openssh and inittab.  
> 
> Here is the inittab entry:
> 
> sh:2:respawn:/usr/sbin/sshd


As many pointed already out, the backgrounding of sshd makes
init respawn. May be you better use `once' or `boot' as action.
I known this will not respawn, if sshd did really die.

A solution would be a flag to avoid backgrounding. I don't
believe the -i is what one wants, because a sshd started that
way does not fork (not sure about that).

Currently you need to run a script either one, which sleeps
and checks sshd according to the contents of the file sshd.pid,
or via a cronjob.

Assuming SYSV-Syntax for ps, a simple cron-entry could look like:

ps -p `cat -s /etc/sshd.pid` > /dev/null 2>&1 || /etc/sbin/sshd

Actually one should check, that the process recorded is really
sshd. A script started with the respawn could look like:

#!/bin/sh
[ -x /usr/sbin/sshd ] || \
 { echo "No daemon /usr/sbin/sshd found">&2 ; exit 1; }
pid=`cat -s /etc/sshd.pid`
while :; do
 [ -n "$pid" ] && cmd=`ps -p $pid | sed -n -e "/^ *$pid/ s,.* ,,p"` || cmd=''
 if [ "$cmd" != 'sshd' ]; then
  /usr/sbin/sshd
  pid=`cat -s /etc/sshd.pid`
  [ -n "$pid" ] || \
   { echo "Unable to start daemon /usr/sbin/sshd found">&2 ; exit 1; }
 fi
 sleep 300
done

With kind regards,
Andreas Schott.
----------------------------------------------------------------
http://www.rzg.mpg.de/~ays           |  :-O   Wissen ist Macht!
email: [EMAIL PROTECTED]             |  8-(   Ich wei� nichts.
phone/fax: +49 89 3299-2180/1301     |  ;->   Macht auch nichts.

Reply via email to