LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Automaticly run script when user logs in? (https://www.linuxquestions.org/questions/linux-security-4/automaticly-run-script-when-user-logs-in-336437/)

bigdog0007 06-23-2005 10:50 AM

Automaticly run script when user logs in?
 
What I have is a non GUI environment. I have written a menu script for running simple diagnostics on my server(i.e. Ping, TraceRoute, IFConfig, NetConfig). What I am trying to create is a user that when they log in it will automatically run this menu script and if they try to break it(Ctrl+C) it will automatically log them out of the system. I have other scripts and files on this server that I do not want them to be able to get into. I have seen similar post but not exactly what I am looking for ... Please help a newb out :D

So here are my questions?:

1) How do I make the Script auto run?
(someone suggested pointing that users shell to the script instead of /bin/bash... but then they can't do anything... did I misunderstand them?)

2) How do I make it log them out if they try to break the script?

3) How do I lock them out of the rest of the system, but still allow them to run the commands above including manually changing the IP address of the server if necessary?


I know this is alot, but any help would be great... Thanks in advance!!

bigdog0007 06-23-2005 02:34 PM

Re: Automaticly run script when user logs in?
 
Quote:

Originally posted by bigdog0007
What I have is a non GUI environment. I have written a menu script for running simple diagnostics on my server(i.e. Ping, TraceRoute, IFConfig, NetConfig). What I am trying to create is a user that when they log in it will automatically run this menu script and if they try to break it(Ctrl+C) it will automatically log them out of the system. I have other scripts and files on this server that I do not want them to be able to get into. I have seen similar post but not exactly what I am looking for ... Please help a newb out :D

So here are my questions?:

1) How do I make the Script auto run?
(someone suggested pointing that users shell to the script instead of /bin/bash... but then they can't do anything... did I misunderstand them?)

Answer: I added ./{filename} to the .bash_profile ... and that seemed to work for me.

2) How do I make it log them out if they try to break the script?

3) How do I lock them out of the rest of the system, but still allow them to run the commands above including manually changing the IP address of the server if necessary?


I know this is alot, but any help would be great... Thanks in advance!!

Now if I can find the answers to the other 2... :p ...Thanks for any responces

afaiq 06-23-2005 02:56 PM

Answer 1
every user has a .bashrc file in their home directory. Put your script in this file and it will get executed every time the user logs in. Note of caution - a user can edit this file and remove your script from it, if they they are linux literate...

bigdog0007 06-23-2005 03:14 PM

Thanks for the warning afaiq

OK... here is what I did to solve all my problems.... I think.

I changed the users Login Shell to point to the script... not sure why this didn't work b4 but now it is....by doing that if the user tries to [BREAK] the script ( Ctrl + C , Ctrl + Z) it either locks the session or does nothing at all...and if they use the "Exit" option from the menu it logs them out.

Is security an issue anymore ... Is there anyway they can get past this? (Yes I know security is always an issue... You know what I mean :p )


All times are GMT -5. The time now is 07:05 AM.