View Full Version : 2nd instance of sshd service

13th December 2011, 11:42 PM
I want to setup a 2nd instance of sshd running but monitoring an alternate port number.
I copied the original init.d/sshd startup script to init.d/sshdalt and modified it to run sshd with the '-p 12345' optional parameter.

It works pretty well except that the original /var/run/sshd.pid file created for the
first sshd instance gets overwritten with the pid of the new alternate sshd. Not really
a problem but a bit annoying in that it effectively disables the systemctl functionality for the
sshd service.

I'd like to modify the system so that a different pid file is created, perhaps
/var/run/sshdalt.pid. How can this be done?

14th December 2011, 02:48 AM
When you start your sshd server you can specify the config file with flag "-f conf_name". Default is /etc/ssh/sshd_config. You can specify your own.
There is a commented line "#PidFile /var/run/sshd.pid" in this default sshd_config file. This line specifies the pid file.
So you need to specify your own configuration file(simply copy sshd_config to sshdalt_config) and use -f flag with your sshdalt start script.
Then uncomment PidFile option in new conf file with another pid name.
Hope it helps.

14th December 2011, 04:47 AM
You can also specify multiple port numbers in /etc/sshd_config. Sshd will then listen on all of them. It sounds like that is all you need and is simpler.