Shell Script for User AUTH Help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for User AUTH Help
# 8  
Old 02-17-2011
I'm sorry I don't quite understand what you're asking. Does your script need to ask for a user name? Please clarify...
# 9  
Old 02-17-2011
and how do i do it in real time usernames and user's password? please advise.

---------- Post updated at 01:58 AM ---------- Previous update was at 01:56 AM ----------

yes please it should ask me for either usernames and type is their password which is the OS/UNIX password to type in and proceed.
# 10  
Old 02-17-2011
So you're wanting to authenticate with the users login and pass that's on the machine they're running it from? Why? Why not just make sure they are a certain user like:

Code:
[`whoami` = "root" ] && echo "I am root"
[`whoami` = "shiv2001in" ] && echo "I am unix.com user shiv2001in"

In other words, your script can test to see who the user is. You can say:
Code:
[ ! `whoami` = "user1" -o "user2" -o "user" ] && echo "You are not authorized to run this script"

# 11  
Old 02-17-2011
because I want only certain users in the admin group to run - once they supply their real/won password the script should continue else should exit out.
# 12  
Old 02-17-2011
Yea see I personally wouldn't want to be "logging in" to your script with my username and password. Leaves a lot to be desired as far as security. If you allow the user to login to the shell, and then test to make sure the user is in fact "user1" "user2" "user" etc, you can make the script exit if they are not on the list.
# 13  
Old 02-17-2011
correct - but, in my case we have lots of admins and I want to allow certain admins only - $who -m|awk '{print $1}' <- if they are these admins only I will allow - becase whoami says root and many admins can sudo to root and they can become root and I do not want those admins or all admins to run this script and want only those who are in my admin group to run this. Hope I'm not making too complicate.
# 14  
Old 02-17-2011
Code:
[ ! `whoami` = "user1" -o "user2" -o "user" ] && echo "You are not authorized to run this script"

This says if you're NOT user1 or user2 or user to echo "You are not authorized to run this script" which can be followed by && exit 1 to make it exit the script immediately if they are not one of those users

Code:
[ ! `whoami` = "user1" -o "user2" -o "user" ] && echo "You are not authorized to run this script" && exit 1

If your setup has `whoami` use it instead of going through `who -m | awk '{print $1}'` does the same thing. Save yourself some typing...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PHP script that detects if auth is required or not on Apache Splunk

I am currently trying to do a PHP script that detects automatically if Apache Splunk authentication is required or not but I'm having a hard time since HTTP code 303 is always coming back, even if auth is required or not. Here is the script so far; <?php /** * Apache Splunk script to... (4 Replies)
Discussion started by: syrius
4 Replies

2. Shell Programming and Scripting

How to Switch from Local user to root user from a shell script?

Hi, I need to switch from local user to root user in a shell script. I need to make it automated so that it doesn't prompt for the root password. I heard the su command will do that work but it prompt for the password. and also can someone tell me whether su command spawns a new shell or... (1 Reply)
Discussion started by: Little
1 Replies

3. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

4. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

5. Red Hat

Proxy auth fails in shell

hi I am using RHEL 5.5. I updated the http-proxy like this http_proxy=http://username:password@IP:port/ When i do ping www.google.com PING www.l.google.com (74.125.236.177) 56(84) bytes of data. then it goes blank. I dont know why. But in the same linux, in gui mode. In... (2 Replies)
Discussion started by: gnanagurus
2 Replies

6. Shell Programming and Scripting

Shell Script to change a user password using script

Hi Experts, I had tried to executes this script to change the user password through script: No lines in buffer #!/bin/ksh cat /etc/passwd | grep -v userid >> /tmp/pass.tmp1 cat /etc/passwd | grep userid >> /tmp/pass.tmp2 PASS1=`cat /tmp/pass.tmp2 | cut -d ":" -f2` PASS2=`q2w3e4r5` sed... (3 Replies)
Discussion started by: indrajit_renu
3 Replies

7. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

8. Shell Programming and Scripting

How do i change to super user then revert back to ordinary user ,using shell script?

Hi all, I am trying to eject the cdrom from a livecd after certain stage... Now assuming that it is possible to eject,please consider my issue!!! The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive... However if i try pfexec eject it... (3 Replies)
Discussion started by: wrapster
3 Replies

9. Shell Programming and Scripting

su to another user in shell script

Hi All, I want some help in creating a shell script. I am running a script thru user1, then I need to su to user2, run a script from that user and return back to user1 and proceed further. Please help me. Abhi (1 Reply)
Discussion started by: akdwivedi
1 Replies

10. UNIX for Dummies Questions & Answers

User Shell script

I'm very new at this -- HELP! I need to know how to terminate a users session when they exit a shell script menu? Any ideas would be much appreciated! Holli (2 Replies)
Discussion started by: HOlli
2 Replies
Login or Register to Ask a Question