0

This is something that I looked into a while back and found some useful info for... but now that I actually need to do it, of course I can't find that guide I saw anymore.

Anyways, here's the situation. I have a program that runs using an ncurses menu through SSH. I want users to be able to login to that program via SSH, but only to that program.

What do I have to do so that this scenario is possible?

  • User opens Putty
  • User signs into the Linux server with their username and password
  • When logging in, they go straight to that program
  • In the even of a program close, crash, cancellation, etc... the user is forcefully loged off of the system.

My goal is to limit them from seeing a command line at all, and to be restricted to just that program. Is this possible? How do I/would I go about doing it?

2

This is also called a captive login.

Append to the user's ~/.profile an execution of the program and an exit.

exec /usr/local/bin/program
exit

Clever users know they can supply a command in their ssh client that isn't the shell you expect. Prevent that with ForceCommand in your sshd config:

ForceCommand

Forces the execution of the command specified by ForceCommand, ignoring any command supplied by the client and ~/.ssh/rc if present. The command is invoked by using the user's login shell with the -c option. This applies to shell, command, or subsystem execution. It is most useful inside a Match block.

Match Group programusers
    ForceCommand /usr/local/bin/program
3
  • A better way is to use command= in the authorized_keys so that you tie a specific command to a specific key. Very useful for backups. – Patrick Mevzek Feb 27 '18 at 3:53
  • A force command may be either in the sshd configuration or in the user's authorized_keys. ForceCommand also works when the user is using non-key (password) auth. And the administrator puts it in one place, versus across all user's key files. – John Mahowald Mar 1 '18 at 14:06
  • Typically, for backups, the client is some automated process so obviously using a key, not a password. And typically the user then is root, not any other user. – Patrick Mevzek Mar 1 '18 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.