LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 07-06-2005, 07:57 AM   #1
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Rep: Reputation: 15
Logging in to Linux box, Securely.


Hi There,

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.

Hope now some one can help me.

Thanks and Regards,
Bharani
 
Old 07-06-2005, 08:08 AM   #2
jtshaw
Moderator
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 63
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.
 
Old 07-06-2005, 09:36 AM   #3
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Original Poster
Rep: Reputation: 15
Hi jtshaw,

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

Kindly guide me with this example.

Thanks
Bharani
 
Old 07-06-2005, 09:39 AM   #4
jtshaw
Moderator
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 63
Code:
#!/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.....

Last edited by jtshaw; 07-06-2005 at 09:44 AM.
 
Old 07-06-2005, 09:49 AM   #5
jtshaw
Moderator
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 63
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...
Any of this help at all?
 
Old 07-06-2005, 11:57 PM   #6
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks Buddy,

But when i execute your second script, got a following error message.

/usr/bin/login_script: line 18: logout: not login shell: use `exit'


But even when using this script, if the user press Ctrl+c then the script gets
terminated and user can access the system. right .

What can be done for this issue ? Kindly help me.

Any way i Thank you for your reply.
 
Old 07-07-2005, 02:11 AM   #7
Kahless
Member
 
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Rep: Reputation: 30
Im not sure I understand what you are trying to do?


do you actally want to be able to do anyting under telnet?

if so, who and what?

is there any good reason you cant use ssh instead?

if so, why not juse use ssh, and disable telnet?
 
Old 07-07-2005, 03:09 AM   #8
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Original Poster
Rep: Reputation: 15
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.
 
Old 07-07-2005, 07:02 AM   #9
jtshaw
Moderator
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 63
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.
 
Old 07-07-2005, 08:42 AM   #10
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Original Poster
Rep: Reputation: 15
Anyway Thankyou....

Hope any one can help :-)
 
Old 07-07-2005, 09:23 AM   #11
sundialsvcs
Senior Member
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 3,685

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
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.
 
Old 07-07-2005, 04:10 PM   #12
Krugger
Member
 
Registered: Oct 2004
Posts: 229

Rep: Reputation: 30
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.
 
Old 07-07-2005, 10:36 PM   #13
twsnnva
Member
 
Registered: Oct 2003
Location: Newport News, Va
Distribution: Debian
Posts: 246

Rep: Reputation: 30
Why don't you just set the script as the shell in /etc/passwd?
 
Old 07-07-2005, 11:36 PM   #14
bharaniks
Member
 
Registered: May 2005
Distribution: Red Hat Linux
Posts: 36

Original Poster
Rep: Reputation: 15
Hi Twsnnva,

Could you give me a short description. I'm unable to get to point.
 
Old 07-08-2005, 02:43 AM   #15
jul3z
LQ Newbie
 
Registered: Jan 2005
Posts: 5

Rep: Reputation: 0
# cat /etc/passwd
...
user:x:100:101:User account:/home/user:/bin/YourScriptHere.sh
...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Distro that will securely clean hard drive? alime Linux - Distributions 7 02-01-2012 06:43 PM
LINUX BOX Logging out pradi_net Linux - Software 1 10-26-2004 01:13 AM
Best Logging software for Traffic through Linux RH 7.3 Box Modem dialup connection sombra_tommy Linux - Software 1 01-05-2004 12:55 PM
Logging in slow to RH 9.0 box tarballed Linux - Newbie 1 07-31-2003 12:03 PM
Programmatically logging on to a Unix Box? concoran Programming 6 07-09-2002 06:51 PM


All times are GMT -5. The time now is 04:24 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration