Re: Use different pid file for second daemon?

From: Nico Kadel-Garcia (nkadel_at_comcast.net)
Date: 11/02/03


Date: Sun, 2 Nov 2003 13:21:20 -0500


"Dale Dellutri" <ddelQQQlutr@panQQQix.com> wrote in message
news:bnmeuv$13p$1@reader2.panix.com...
> 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.

You need to create a separate init script, called say "sshd-external", and a
separate sshd_config file for it to use, say "sshd-external_config". Then
read the manual page for "sshd_config" and change the "PidFile" entry
appropriately, along with any other desired settings.

> 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).

Bingo. Yeah, you need a separate init script. Or look into how the "vsftpd"
init script does things to find multiple config files and handle them
separately: it's really quite clever.

> 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)?

No need. See above...



Relevant Pages

  • 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, ...
    (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)