Operating System - HP-UX
1751906 Members
5248 Online
108783 Solutions
New Discussion юеВ

secsh - how to edit to manage multiple sshd daemons

 
SOLVED
Go to solution
TheJuiceman
Super Advisor

secsh - how to edit to manage multiple sshd daemons

Hi gang,

I have set up a secondary sshd daemon to run on a separate port. My question is this...how can I edit the secsh script to successful stop and start all instances of my sshd daemons at bootup/shutdown? Thanks.
6 REPLIES 6
Tingli
Esteemed Contributor

Re: secsh - how to edit to manage multiple sshd daemons

You can set the sshd configuration file by starting sshd in sshd -f sshd_conf_2.
TheJuiceman
Super Advisor

Re: secsh - how to edit to manage multiple sshd daemons

Let me clarify what I'm looking to do. I know how to start the daemon via command line. I'm wanting to be able to stop/start the daemon at bootup/shutdown.
Steven E. Protter
Exalted Contributor

Re: secsh - how to edit to manage multiple sshd daemons

Shalom,

If you configure the sshd_config and the ssh_config files as instructed to run multiple daemons, the start/stop for secure shell will handle this for you.

Make the changes:

/sbin/init.d/secsh stop
/sbin/init.d/secsh start


Do some testing to make sure the configuration changes work.

Running openssh/secure shell on more than one port is a PITA and I'd have solid reasons for doing so.

SEP

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Olivier Masse
Honored Contributor

Re: secsh - how to edit to manage multiple sshd daemons

I had the same need as you and ended up making a modified version of the secsh script that I have attached here.

It calls the daemon with an alternate config file but care must be taken as the original secsh script kills anything that is named "/opt/ssh/sbin/sshd" when you ask it to stop; hence it kills both your daemons at once which is not desirable. So I hardlinked /opt/ssh/sbin/sshd to /opt/ssh/sbin/224sshd and start it with the link instead in my script so that it doesn't get killed.

Olivier
TTr
Honored Contributor
Solution

Re: secsh - how to edit to manage multiple sshd daemons

It might be simpler to create another set of startup files cripts such as

/sbin/rc2.d/S394secsh (linked to /sbin/init.d/secsh2)
/sbin/rc1.d/K605secsh (linked to /sbin/init.d/secsh2)
/sbin/init.d/secsh2
/etc/rc.config.d/sshd2

In /etc/rc.config.d/sshd2 ensure that you add options in SSHD_ARGS to use a different config file and port.

In /sbin/init.d/secsh2 you must change the WHAT, and WHAT_CONFIG values to point to the alternate files.

The WHAT_PID is a problem. You need to specify a different PID path for the second daemon in the config file and add it here.

Also in the start section you have to add a "-w" in the grep for the evaluation of the "NOT_RUNNING" variable because the grep will capture both sshd processes.

grep -w "/opt/ssh/sbin/sshd"
grep "/opt/ssh/sbin/sshd -p XX" where XX is the port number of the second daemon.
TheJuiceman
Super Advisor

Re: secsh - how to edit to manage multiple sshd daemons

TTr...that is exactly what I needed. Thank you very much!!!