is there a way to just execute a command (or script) on a user (ssh) login and then exit?
some kind of replacing the default shell with a custom script.
i want a user only be able to restart a service, but not to have regular shell-access
In Ubuntu I was able to create a script that restarted the service. Then in the user's /etc/passwd entry I set the script as the login shell (the last field).
The way you want to do this is by using ssh keys, and set the command associated with the key in the user's .ssh/authorized_keys file. A quick google gives me this, specifically the "Forced command" section.
Edit: The second part of this is to passwd -l the user so that password-based login is impossible.
In Ubuntu I was able to create a script that restarted the service. Then in the user's /etc/passwd entry I set the script as the login shell (the last field).
from /etc/passwd:
testaccount:x:1001:1001:1,,:/home/testaccount:/home/testaccount/login.sh
The way you want to do this is by using ssh keys, and set the command associated with the key in the user's .ssh/authorized_keys file. A quick google gives me this, specifically the "Forced command" section.
Edit: The second part of this is to
passwd -l
the user so that password-based login is impossible.Something Like that?