Red Hat Bugzilla – Bug 826720
sshd initscript clobbers other sshd processes.
Last modified: 2013-02-21 05:27:53 EST
Description of problem: Initscript clobbers other sshd processes. Please note that this is NOT the same issue as 698777, as we are already running seperate pid files. The problem is that the existing initscript doesn't use them.
Version-Release number of selected component (if applicable): openssh-server-5.3p1-70.el6_2.2.x86_64
How reproducible: Completely
Steps to Reproduce:
1. Create a second sshd instance listening on a different port (ex. copy the sshd initscript, call it "sshd_alt" or something, then change the pid name, config files, make sure it uses -f to talk to a secondary config file, etc).
2. Copy sshd_config to" sshd_config_alt" or something (match the earlier step).
3. Start both instances.
4. Stop one of the instances (ex. the original one).
The secondary instance is stopped. The primary might stop too, but I didn't check.
Only the instance that corresponds with the initscript should stop.
The initscript does unsafe things that interfere with other ssh daemons, like this:
The PID file is already available as a variable, so the killproc should probably look something like this:
killproc -p $PID_FILE $SSHD
It looks like a similar problem may be affecting the configuration validation, etc.
The init script needs a complete rethink and rewrite. All variables moved to /etc/sysconfig/`basename $0`, variables derived dynamically from /etc/ssh/sshd_config or other specified file, etc.
Created attachment 624155 [details]
This is fixed sshd.init using "killproc -p $PID_FILE $SSHD". It's also slightly changed to simplify process of creating multiple sshd instances. Following steps should work to setup a second sshd instance on the port 2222:
# cp /etc/init.d/sshd /etc/init.d/sshd-second
# cp /etc/sysconfig/sshd /etc/sysconfig/sshd-second
# echo 'OPTIONS="-f /etc/ssh/sshd_config-second -p 2222 -o PidFile=/var/run/sshd-second.pid"' >> /etc/sysconfig/sshd-second
(plus some SELinux changes)
> # echo 'OPTIONS="-f /etc/ssh/sshd_config-second -p 2222 -o
> PidFile=/var/run/sshd-second.pid"' >> /etc/sysconfig/sshd-second
If you use -f /etc/ssh/sshd_config-second then you also need to change SSHD_CONFIG variable in the new sshd-secong initscript
Comment on attachment 624155 [details]
This initscript is wrong.
Starting S15sshd: [ OK ]
> The initscript does unsafe things that interfere with other ssh daemons,
> like this:
> killproc $SSHD
> The PID file is already available as a variable, so the killproc should
> probably look something like this:
> killproc -p $PID_FILE $SSHD
will be fixed in next release. Thanks.
> It looks like a similar problem may be affecting the configuration
> validation, etc.
(In reply to comment #3)
> The init script needs a complete rethink and rewrite. All variables moved to
> /etc/sysconfig/`basename $0`, variables derived dynamically from
> /etc/ssh/sshd_config or other specified file, etc.
This would need big change with high regression risc, bugs and so, see my comment #c6. This
scripts hasn't been supposed to be used in multinstance environment. I won't do this.
Please fix your sshd.init copies to avoid problems with configuration validation, sysconfig file and so.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.