First time here and posting just because I can't seem to find the answer to this, or whether is this even possible.
The problem I'm having is that I want to create a script that will be run immediately after a user logs on to my server using Putty, for example.
I don't want the user to be able to perform any of the normal commands you could run, instead I want to create a script that will respond to certain set of pre-defined commands, for example,
> Hello
Hello, username goes here
Is this possible to do it?
Using SSH is not a prerequisite, any other console connection, telnet, for example, will do as well, I just want a user to be able to connect to my server and get response from some basic commands.
Thank you for your time, I hope I've explained myself clearly enough.
Best Answer
You can accomplish this kind of behaviour by changing the shell of the account in question to the script you want to be run. In that case, the user does not get its normal prompt, where to enter normal commands like
ls
,cd
etc. at all. Instead your script is run at login and you may there have the functionality you need.To change the shell, you can use
chsh
-command or change it directly into/etc/passwd
. The new shell (your script) must also be listed in/etc/shells
for this to work.