nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

How to authenticate users in shell scripts

This is a discussion on How to authenticate users in shell scripts within the Shell scripting forums, part of the Development/Scripting category; Hi All, I need a script which should authenticate the 2 users present in the server and then proceed with ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2009, 09:26 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
udayakumar is on a distinguished road
Default How to authenticate users in shell scripts

Hi All,

I need a script which should authenticate the 2 users present in the server and then proceed with the script.

The scripts should as follow:

It should ask the first user id, then his password, if its ok then it should ask for the second user id and its password, if its successful it should proceed with the script.

I have written through this ssh, but not satisfied. I have tried with su also,but could not succeed.

Any help is Appreciated.
Reply With Quote
  #2 (permalink)  
Old 05-05-2009, 09:55 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,644
Thanks: 11
Thanked 232 Times in 172 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You can't do that with shell script. You need to use real programming language like C or Perl to do that. Can you tell us more about what you are trying to do here? May be we can suggest something else...
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 05-06-2009, 08:15 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
udayakumar is on a distinguished road
Default How to authenticate users in shell scripts

Whenever a admin wants to reboot a machine, he will be asked to enter the details of the change record and atlast two other admins should authenticate and then reboot will be performed. We want to log all these information..
Reply With Quote
  #4 (permalink)  
Old 05-06-2009, 10:52 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Posts: 2,644
Thanks: 11
Thanked 232 Times in 172 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Standard Linux and UNIX systems record everything done by users including log of command run by users and system rebooting time. You need to setup sudo to delegate job and turn on system accounting for auditing purpose. No one writes script for this kind of work.

Try following tutorials for more info:
  1. How to keep a detailed audit trail of what’s being done on your Linux systems
  2. Linux last reboot time and date find out
  3. Allow a normal user to run commands as root under Linux / UNIX operating systems
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #5 (permalink)  
Old 05-22-2009, 02:11 PM
Junior Member
User
 
Join Date: May 2009
Location: Chennai
OS: Debian
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
antonydick is on a distinguished road
Send a message via MSN to antonydick Send a message via Yahoo to antonydick Send a message via Skype™ to antonydick
Smile Re: How to authenticate users in shell scripts

Hey Udayakumar,

I am a beginner to linux but still i thought this bit of script will be useful to you

echo "Enter your username:"

read username

if [ "$username" = "antony" ]

then

else

fi
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
SSH - Passing Unix login passwords through shell scripts arulkumarr Shell scripting 4 08-27-2008 10:22 PM
Squid server to authenticate with Windows Active Directory aasif.shaikh Getting started tutorials 2 05-31-2008 05:50 PM
shell scripts required for students roni Shell scripting 6 07-20-2007 07:21 PM
running command a root in shell scripts chiku Shell scripting 1 07-17-2006 07:39 PM
shell script for finding users not logged on for last 10 day ganes Shell scripting 4 07-06-2005 12:01 PM


All times are GMT +5.5. The time now is 11:49 AM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38