Use different pid file for second daemon?

From: Dale Dellutri (ddelQQQlutr_at_panQQQix.com)
Date: 10/28/03


Date: Tue, 28 Oct 2003 19:10:23 +0000 (UTC)

Is there any way to change the pid file that sshd uses when it starts?

My first sshd daemon listens to the internal network port, and I need
to run a second sshd daemon listening to the external network port and
be able to control it separately from the first. I wanted to set it
up as a service under RH9 using a different name. Unfortunately, the
man for sshd specifically says that the pid file:
  /var/run/sshd.pid
    Contains the process ID of the sshd listening for connections (if
    there are several daemons running concurrently for different
    ports, this contains the process ID of the one started last).
There does not seem to be an option to change this.

This causes a problem because to stop the original sshd process, root
would usually invoke:
  service sshd stop
but this uses /etc/init.d/sshd, and the stop portion of the script
uses the pid found in the pid file to stop the process (which would be
the second one only).

How can I get the second daemon to use a different pid file without
rebuilding sshd from source? (And I don't even know how to rebuild it
from source.) Would copying the sshd daemon to another name and
patching the new executable work (string /usr/sbin/sshd does show
/var/run/sshd.pid)?

-- 
Dale Dellutri <ddelQQQlutr@panQQQix.com> (lose the Q's)


Relevant Pages

  • Re: Use different pid file for second daemon?
    ... > Is there any way to change the pid file that sshd uses when it starts? ... > My first sshd daemon listens to the internal network port, ... you need a separate init script. ...
    (comp.security.ssh)
  • Re: SSH newbie questions
    ... It gets created when sshd starts. ... changing the configuration file, the PID file wasn't created. ... as root, then an sshd process starts, and the .pid file is created. ...
    (comp.sys.mac.system)
  • Re: FreeBSD Security Advisory FreeBSD-SA-03:12.openssh
    ... >> All the restart target does is basically kill the pid using the pid file ... >> and then restart the daemon, so it is no more dangerous then the below. ... >every SysV sshd script is as sensible. ... None of these are problems when sshd is run from inetd. ...
    (FreeBSD-Security)
  • Re: SSH newbie questions
    ... Since you didn't restart sshd after changing the configuration file, the PID file wasn't created. ... It appears now because, in rebooting your machine, you also restarted sshd, which read teh new configuration file changes, and created the PID file. ...
    (comp.sys.mac.system)
  • RE: X11 Forwarding
    ... we need to restart the sshd daemon. ... The trick is to HUP only the highest sshd process. ... First do a "ps -f" to get the PPID ... UID PID PPID C STIME TTY TIME CMD ...
    (SSH)