setting passwd in script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users setting passwd in script
# 1  
Old 03-30-2005
setting passwd in script

HP-UX 11

I currently have a script that is running useradd and passwd commands to automate setting up new users. It was originally designed so that passwd was run with -d -f to delete a passwd and force user to set passwd at next login. Now mgmt wants instead to set a first-time passwd and have the user change it at next login. Assuming the script "knows" (that is, has passed to it) what to use as a first-time passwd, how can I set it?
useradd doesn't seem to have that option
passwd only will do it interactively and I don't have *expect* to handle this - I thought maybe sam commands could do it - but now I can't find the man page for those to double check. Any ideas?

Lisa
# 2  
Old 03-30-2005
You could obtain expect at The HP-UX Porting and Archive Centre. As for sam, it is interactive by nature. But it uses an undocumented feature. /usr/sam/lbin/useradd.sam is a symlink to useradd. userradd checks its name. If it's useradd.sam, a -p option becomes available. However the argument must be the encrypted password. It's hard to encrypt a password in a ksh script. But this might be an ioption if you have the encrypted string. Also I wrote a script that uses telnet to change passwords on multiple systems. That technique could be used to change a password on the localhost.

changepass automate password changes on multiple systems
# 3  
Old 03-31-2005
Quote:
Originally Posted by Perderabo
If it's useradd.sam, a -p option becomes available. However the argument must be the encrypted password. It's hard to encrypt a password in a ksh script. But this might be an ioption if you have the encrypted string.
LisaS ... set your password to something generic and use the encrypted string in your script ... then reset your password so your password is different from the one the script uses ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh passwd less, shell script

Hi All, Wishes!! I need some help to prepare a script to copy the public key from admin host to multiple client hosts to make them login without password. Detailed : I have an admin host "admin1" and i generated sshkeygen, now i have id_rsa.pub and i have around 50 client hosts. i... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies

3. Shell Programming and Scripting

Need script to monitor change in /etc/passwd

Hi All, From Audit point of view, I need to add a script to my production Solaris servers. That should be able to mail me, if any user is added or removed. That means, I should get a mail, what user is deleted or added in /etc/passwd, i.e. if there is a change in this file, I should be... (8 Replies)
Discussion started by: solaris_1977
8 Replies

4. Solaris

Solaris passwd script

Hello all, Since Solaris passwd does not have --stdin option can you advise how to change the password for 30 users with a script. The password can be the same one. I`ve tried already echoing, xargs, cat and similar. Thanks. ---------- Post updated at 04:04 AM ---------- Previous update... (0 Replies)
Discussion started by: click
0 Replies

5. Shell Programming and Scripting

Modify /etc/passwd via script

We have a business need to modify the /etc/passwd file every time a new user gets added, because the user ID begins with a zero. When you create the new user in smit, even if you put the leading zero in, it does not retain it when the entry is added. That being said, I need to create a script... (11 Replies)
Discussion started by: mshilling
11 Replies

6. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

7. Shell Programming and Scripting

passwd on a simple script

hi guys I am working on a script which is basically a menu for some linux operators... I need on this menu for the operators the option to change the password... This are 2 linux servers using Linux heartbeat. what I need is to change change the password using passwd command and replica... (10 Replies)
Discussion started by: karlochacon
10 Replies

8. Infrastructure Monitoring

need script for passwd , can't use expect tool

Hi , as others users here , i'm searching for a script which can automate "passwd" dialog . I saw threads about "expect tool" but on my platforms , "C" product isn't installed and i'm not the admin so i can't install it. is there another way to do it , with a "simple" shell script ??? ... (35 Replies)
Discussion started by: Nicol
35 Replies

9. Shell Programming and Scripting

passwd in shell script

Is there a way to change user password using passwd command in shell script? I don't want to use expect. Please help (8 Replies)
Discussion started by: corny
8 Replies

10. Shell Programming and Scripting

passwd -l script

I need to lockout about 250 user accounts on a server. I figure on putting the user accounts to be locked out in a text file and the running a script to go through the file and run the "passwd -l useraccount" against the /etc/passwd file (yes, I am root as I do this). Here is what I have so... (3 Replies)
Discussion started by: antalexi
3 Replies
Login or Register to Ask a Question