Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Can any one suggest me to make a user more secure for my requirment.
My Requirement :
When a user (ABC) conects to the system through telnet, a script will
be executed. Where its initiated on ".bashrc" file of the user "/home/ABC".
Now if the user ABC press "Ctrl + c" the script ends where he can access
the system for all purpose. But my requirement is, when the user ABC
terminates the script then the telnet session should be disconnected.
Already i have raised my query before a month, but i din't get a solution.
If whatever your script does doesn't background itself (ie, it executes and doesn't let the bashrc to continue to be interpreted until it is finished) then just exec logout as the next command after the script runs.
Oh ya... and I have to give you the obligatory "telnet is inherently insecure, you probably want to use ssh instead" warning.
Thankyou for your reply, But i din't understand your point.
My Script is below.
#!/bin/bash
echo "Do you want to work ?"
echo "If YES-1 or NO-2"
read cho
if [ $cho -eq 1 ]
then
"DO THE GIVEN PROCESS"
if [ $cho -eq 2 ]
then
"THE USER SHOULD BE TERMINATED"
else
"THE USER SHOULD BE TERMINATED"
fi
fi
#!/bin/bash
echo "Do you want to work ?"
echo "If YES-1 or NO-2"
read cho
if [ $cho -eq 1 ]
then
"DO THE GIVEN PROCESS"
logout #called after the given process completes
else
logout # called if answer to question above wasn't 1.
fi
Edit: I just tested this... works better without the execs.....
Ok... here is another little example I threw together...
Code:
echo "Do you want to work ?"
echo "If YES-1 or NO-2"
read cho
if [ $cho -eq 1 ]
then
echo "Working!"
echo "You done? (1 = yes, 2 = no)"
read cho2
while [ $cho2 -eq 2 ]
do
echo "Working!"
echo "You done? (1 = yes, 2 = no)"
read cho2
done
fi
logout #logs them out after they are done...
My requirement is to make the system as a simple proxy server, using which it should
connects to our main proxy server and does the process of files downloading
and uploading.
In this scenario we create a new user in the SPS (Simple Proxy Server) and by using it
we access the MPS (Main Proxy Server) for which only one user login is provided.
So if we provide the user name and passwd of SPS to a particular user then he can access
all the contents of the system, for which i have gone to this tunnel of making the process
using scripting so that the user can only be able to do the particular process.
Can you tell me what is the difference between a normal "telnet" and "ssh"
know as secured access but not more than that.
Is there any more options on this ssh, please guide me.
As far as I know (and I'm no expert on this) there is no way to catch signals (ctrl-C is a signal) with a bash script. If you were having it execute a C application I could help you there.
To get ride of that error, change logout to exit... other then that I'm not sure where to go from here.
You definitely want to start this user, not under an unlimited shell (like bash), but under a restricted shell ... one that will execute a certain command and then log out, never allowing the user access to an unrestricted command-prompt.
I suggest that you start with man bash, which describes the restricted-shell features that are available in bash.
As jtshaw correctly mentions, "Control+C is a signal," and there is extensive discussion of signals in the aforementioned man-page. (See also man 7 signal for a list of signals, their acronyms, and what causes them to occur. For example, Control+C is, SIGINT. Execute the command "stty -a" for a complete list of which control-charcters do what... (The stty command can also redefine those settings or remove their special actions.)
It is also useful to know that any program can be specified as the user's "shell." When the user successfully completes login, the specified shell-program is executed and that program is "the user's session."
For instance, the /sbin/nologin program exists to print a message that "this account is currently not available" and then exit. If this program is specified as the shell of certain accounts, then it effectively prevents login to these accounts because it is "the shell" and because it does nothing.
It is also possible to set up "kiosk-type services" by modifying the /etc/inittab This is the file that actually tells Linux to start the program which prompts for your login. If you want a totally-dedicated service to run on one of your serial-lines, i.e. no concept of "logging in" as far as Linux is concerned, you can use this mechanism to start your program and to arrange for it to be constantly "re-spawned" each time it dies.
So there really are a variety of options available to you. You can set up your system to be just as restrictive as you want.
can't you just right a small program up and then put it as his shell in /etc/passwd.
This way when he logs in your script runs and it isn't a shell so he hopefully won't be able to get out. You can catch Ctrl + C, in bash I don't know how.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.