in reply to Re^2: SSH daemon in Perl?
in thread SSH daemon in Perl?

How can I make the OpenSSH server execute this program upon connection without creating any user accounts?

You'll need one user to actually own the process running the perl script but it can be the same user serving all your clients. Then use ForceCommand to ensure that they can only execute echo.pl. You can/should also set that user's shell to something suitably restrictive.

Replies are listed 'Best First'.
Re^4: SSH daemon in Perl?
by robs87 (Novice) on Jun 22, 2016 at 23:11 UTC

    Yes, one user will execute the Perl program. However, is it possible to execute the program immediately upon connection without logging in with a Unix user account?

    Going back to the example of the SSH chat server written in Go (https://medium.com/swlh/ssh-how-does-it-even-9e43586e4ffc), a client can enter ssh hostname in their terminal and enter the "chat room" without logging in.

      To reword the question:

      "upon connection" means there is 'something' listening on port 22. This 'something' (e.g. your server) already has to run beforehand (waiting for the actual connection and doing the authentication thing, as you yourself already stated).

      Under which user shall this 'something' run? This could be a single non-privileged user account "mycoolservice" dedicated exclusively to that ssh daemon.

        The original goal was to write an SSH daemon in Perl, but haukex suggested using the OpenSSH server instead.

        Under this model, there will be no Perl SSH daemon. Instead, there will be a simple Perl program that reads input from STDIN and sends output to STDOUT. This program will be executed by OpenSSH upon connection.

        Yes, OpenSSH will execute this program as a single non-privileged user. However, it's important that I do not have to log in as this user upon connection.

        Here's a sample of what the session output should look like:

        $ ssh abc123@localhost Hello, world! Hello, world! $ ssh asdfghjkl@localhost This is a simple echo server as an example. This is a simple echo server as an example.

        Notice that no authentication takes place. It proceeds to execute echo.pl (as the single non-privileged user) regardless of the username that was sent.