Ssh – configure multiple sshd instances on debian 8 (jessie) systemd

debiandebian-jessiesftpssh

I would like to run two sshd daemons on debian 8 (using openssh), one for administration and one for sftp.

This used to be quite easy in debian 7 but with systemd it is more difficult.

So far I have created the sshd_config_second and the ssh_config_second.

How would I create a service file for sshd_second.service and start the daemon?

I looked into the sshd.service but this does not reference the sshd_config file. Where do I feed the daemon these config files?

Update:

I followed this from RHEL7 and was successful:

https://access.redhat.com/solutions/1166283

Best Answer

The default Debian 8 systemd sshd unit is in /lib/systemd/system/ssh.service and is pretty simple. All you would need to do is something like cp /lib/systemd/system/ssh.service /etc/systemd/system/ssh_sftp.service then edit your file to be something like this.

[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStart=/usr/sbin/sshd -D -f /etc/ssh/sshd_sftp_config $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target
Alias=ssh_sftp_d.service

After creating that file, enable and start it. systemctl enable ssh_sftp.service and systemctl start ssh_sftp.service.

Like @Michael Hampton suggested, basically the exact same set of instructions as what was suggested for the Redhat.

Related Topic