Running two SSH servers

Is this above mentioned in title possible ? I want to run one SSH server for SFTP clients (on some other port.. for ex 2121 ), and want to run other SSH server for SSH clients which will be allowed to log in only with key. Anyone have Idea how to implement this ?

tnx


Solution 1:

Use separate config files and start one of the servers specifying the config file. To use a different file use -f option followed by the config file you want to use.

If you want to make this persistent, you will need to create a copy of the init.d script that starts sshd and modify it to use a different pid and the new configuration file. More modern distributions use systemd which uses different control files, for which you will need to create new copies.

It may be possible to achieve what you want with a single sshd and a Match block. (as mentioned by joschi). You will need to add the additional port(s) and/or address(es) to the configuration. Match will only allow some properties to be changed. See the documentation for sshd.config which may be output by the command man sshd_config. You match line might look like:

Match LocalPort 1022

Solution 2:

Alternatively to the solution posted by BillThor (using two seperate configuration files) you might want to check the Match directive in sshd_config(5) which can be used apply different configurations per user/group/client IP address.