Password script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Password script
# 1  
Old 11-13-2003
Password script

Is there a simple way to do a script for password changes? I need to let our help desk folks (for example) change user passwords. Currently, I have set them up with root privileges for doing this. I know this is not a good way, but what are my other choices? I was thinking of a script where (thru the script) the help desk folks would get temporaray root privileges, then change somebody's password, and before exiting out of the script have their own privileges back. Can this be done? If I use the 'su' command, then I have to know the user's password before I can change it. This is not always possible.

Just wondering..... Smilie

Thanks in advance.
Latha Nair
# 2  
Old 11-13-2003
Hi there, this is possible, if you create your script you then need to set a sid or sticky bit on the script, this will then give the script temporary root privilages on the system, this can be achieved using chmod +s

Hope that helps
# 3  
Old 11-13-2003
I am a new user, and I do not know how to use what you have explained. I read thru some of the emails in this area, and most everybody advises to use 'expect'. I am checking into that possibility. If you can explain a bit more about your advice, that would be very helpful.

Thank you.
Latha
# 4  
Old 11-14-2003
Someone please correct me if I am wrong, but I think the way to use this is:

chmod +s <file in question>
# 5  
Old 11-14-2003
New users shouldnt be writing scripts to allow other users to change passwords,, a helpdesk person could change roots pass and ruin the system,,, but if you must, then id say give them sudo access to the passwd command
thangorn
# 6  
Old 11-17-2003
I wouldn't give them access to the actual passwd program. It would be better to give them access to a wrapper that checks to ensure that they can only change passwords for users, for example.

passwdwrap.sh (used as passwdwrap.sh <user>)
Code:
#!/bin/ksh

# some lame metacode....

SET TRAPS FOR EXIT CONDITIONS

if [ $1 == "root" ]
then
     logger -p local1.error -t PASSWDWRAP "ERROR: unauthrorized root change attempted"
     exit 1;
else
     passwd $1
fi

I would be more likely to write such a tool in C to prevent modification etc. I'm sure there are better examples out there, but I hope this gives you something to think about. Not sacrificing security for ease should always be foremost in your thoughts.

Cheers,
Keith

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 05:04 PM..
# 7  
Old 11-17-2003
Thanks for all who answered.

The whole point of this script is that none of us are very good with UNIX here. I am entrusted with a system that I am trying to learn. I know how to change user passwords thru smit. In order for the help desk folks to change user passwords thru smit, I had to give them root equivalent privileges. That is what I am trying to change by having a script thru which they can have root privileges TEMPORARILY so that they can accomplish the follwoing:

1) Have their regular access to execute the script
2) The script could provide them with root privileges
3) Then change the user's password
4) After the password is changed, the script will set the help
desk folk's privilege back.
5) Exit out of the script.

When they exit, they would have their original privilege set again. This is what I am trying to accomplish. Is this possible? If I was not clear earlier, I am sorry.

We have an AIX/UNIX system.

Thank you.
Latha Nair
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Password sent via reset password email is 'weak' and won't allow me to change my password

I was unable to login and so used the "Forgotten Password' process. I was sent a NEWLY-PROVIDED password and a link through which my password could be changed. The NEWLY-PROVIDED password allowed me to login. Following the provided link I attempted to update my password to one of my own... (1 Reply)
Discussion started by: Rich Marton
1 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

SFTP prompting for password even though password is in script

Hi All, I am trying to transfer a file from one server to a remote server using SFTP. Client is not ready for key setup. I am working on Solaris 10. Here is the code. #!/bin/ksh # sample automatic Sftp script to dump a file USER="user1" PASSWORD="pass1" HOST="host1" sftp $USER@$HOST... (6 Replies)
Discussion started by: megha2525
6 Replies

4. Shell Programming and Scripting

Make a password protected bash script resist/refuse “bash -x” when the password is given

I want to give my long scripts to customer. The customer must not be able to read the scripts even if he has the password. The following command locks and unlocks the script but the set +x is simply ignored. The code: read -p 'Script: ' S && C=$S.crypt H='eval "$((dd if=$0 bs=1 skip=//|gpg... (7 Replies)
Discussion started by: frad
7 Replies

5. Shell Programming and Scripting

How to use the password in my script?

Hi Gurus, I have an issue to use the passwd in my script. in the script, I need log into the ftp server and get file. I put the user name and password in my script, but each time when I run the script, it still ask the password. I am wondering, is there any way I can put the password... (3 Replies)
Discussion started by: ken6503
3 Replies

6. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. 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

8. Shell Programming and Scripting

Help with password script

Can someone look at the below code and let me know what's wrong with it. I keep getting syntax error on line 24 in the script. This is the full command from line 20-30 pw=" " password = "password"# while ] do read -s -p "Enter password:" pw echo " " if ] then echo " Correct password... (1 Reply)
Discussion started by: bbbngowc
1 Replies

9. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

10. UNIX for Dummies Questions & Answers

Please help me out with this password script

pkay, I wrote a very long shell program to manage the task of creating user accounts now, the script I wrote that sets a temporary password for users makes it possible for anybody to see it. what I mean is that, when I type the temp password for the new user, it shows the exactly letters am... (1 Reply)
Discussion started by: TRUEST
1 Replies
Login or Register to Ask a Question