I have a machine with two nics. I need to setup ssh rules. One with private/public key for the public access and one with no restriction for the private lan access. Assuming that you are using openssh rpm package of your favorite distro.
I decided to put this blog so that people would not spend a lot of time discovering how to setup 2 sshd daemons..
1. cd /etc/ssh2. cp sshd_config sshd2_configEdit sshd2_config and change the ff:
PidFile /var/run/sshd2.pid3.
ln -s /usr/sbin/sshd /usr/sbin/sshd24.
cd /etc/rc.d/init.d/5.
cp sshd sshd2Edit sshd2 and change the ff:
config: /etc/ssh/sshd2_configpidfile: /var/run/sshd2.pid[ -f /etc/sysconfig/sshd2 ] && . /etc/sysconfig/sshd2prog="sshd2"SSHD=/usr/sbin/sshd2PID_FILE=/var/run/sshd2.pid6. Create a file
/etc/sysconfig/sshd2 and put the ff:
OPTIONS="-f /etc/ssh/sshd2"The new sshd2 init script will try to source a configuration file in
/etc/sysconfig/sshd2. In this configuration file we will tell the SSH daemon to start up with a different SSHD configuration file from the default
/etc/ssh/sshd_config:
If your system has PAM enabled you will also need to provide a separate PAM configuration file for the new sshd-internal service. To keep things easy we are just going to link to the default sshd configuration file for PAM:
cd /etc/pam.dln -s sshd sshd-internal7. Finally, start sshd2
/etc/init.d/sshd2 startThe advantage of providing a separate sshd2 binary through a symbolic link to the original sshd is that both running SSH daemons will always use the same application version. This is also true after an update of its RPM package for example