Sponsored Content
Top Forums Shell Programming and Scripting Modify users password via script? Post 302132170 by zazzybob on Wednesday 15th of August 2007 05:46:37 PM
Old 08-15-2007
This is on an ESX 3.x.x box, but you've got a few options.

The first is to use the --stdin option to passwd, e.g.
Code:
# useradd -m -d /home/foo foo
# echo "foo" | passwd --stdin foo
Changing password for user foo.
passwd: all authentication tokens updated successfully.

This would require you storing the plain text password in your script. A *much* safer option is to add a user and set the password as you normally would to a standard value, e.g.
Code:
# useradd -m -d /home/tmpuser tmpuser
# passwd tmpuser
...

Now, you can use the encrypted password for this user when creating other accounts, so that all newly created accounts have the same password as "tmpuser", e.g.
Code:
# useradd -m -d /home/newuser -p `awk -vFS=':' '$1 ~ /^tmpuser/ {print $2}' /etc/shadow` newuser

Cheers,
ZB
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Setting password restrictions for all users

I would like to change the password requirements for all our AIX 5.2 logins but am having trouble finding a place where I can set the rules for everyone at the same time. I know I can go user by user in smit passwords but is there a way to create rules for everyone at the same time? Thanks,... (2 Replies)
Discussion started by: drathbone
2 Replies

2. UNIX for Dummies Questions & Answers

Have users changed their password

How can I know users have changed their passwords ? I don't need their password (!) I have to know if they have changed their pass word and when ? Thank you in advance for any SIMPLE answer. (6 Replies)
Discussion started by: annemar
6 Replies

3. HP-UX

How to enforce users not to modify their command history.

As a system administrator. sometimes we see the users are trying some commands dangerous for the system health and remove them from their individual coomand history file. How it is possible to enforce that the normal usres will will not be able to modify the history. Thanks in advance. Partha (4 Replies)
Discussion started by: partha_bhunia
4 Replies

4. UNIX for Dummies Questions & Answers

Need to sort/change modify 2300 users ...

Ok, so here's my project I've been given and I know very little about this. I have an AIX unix box that has over 2300 local users. Any user with 4 or less characters in the username does not get changed. Any user with 5 or more needs to have the attribute shell=/bin/ksh changed to... (1 Reply)
Discussion started by: tresani
1 Replies

5. Shell Programming and Scripting

script to change password for all users

We have a server where we have a number of user ids and we also have the list of old passwords in a CSV file. Now we want to change the password of all the users and assign them a default password.Can we write a shell script to do that. I am planning to read the user name and corresponding... (7 Replies)
Discussion started by: dr46014
7 Replies

6. UNIX Desktop Questions & Answers

Too many users with root password

Hi there, I'm working with a Linux server and now I can get a daily Logwatch mail ... my question is:since there are too many users with root password (...in my opinion... :mad:) how could I prevent to delete information about "su" log? Thanks in advance, GB (3 Replies)
Discussion started by: Giordano Bruno
3 Replies

7. Solaris

Change password for users

I am on SunOS SolarisServer 5.11 11.1 i86pc i386 i86pc , I am trying to change password for a user,but I get the following message.I cannot find any google help on the matter.can anyone help? root@SolarisServer:~# passwd passwd: Changing password for stain Please try again Please try... (6 Replies)
Discussion started by: cbtshare
6 Replies

8. Solaris

How to programmatically reset a users password.?

Hello all, I have a small C++ app for my solaris admins. I need to set it up so they can reset a users password. The admin does not have the old password. How can I reset a users password to a temp password either using passwd or PAM? I need to do this from within my C++ app. I have searched... (3 Replies)
Discussion started by: ChickenPox
3 Replies

9. Shell Programming and Scripting

To exclude users in password file

Hi, I want to exclude the users below 500 in the password file with the below script. #!/bin/bash # get date in dd-mm-yyyy format NOW=$(date +"%d-%m-%Y") exec > "/root/SYSINFO/User_details_`uname -n`_$NOW.txt" cut -d: -f1 /etc/passwd > /tmp/pass.txt && for i in `cat /tmp/pass.txt`;... (2 Replies)
Discussion started by: gsiva
2 Replies

10. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies
NEWUSER(8)						      System Manager's Manual							NEWUSER(8)

NAME
newuser - adding a new user SYNOPSIS
rc /sys/lib/newuser DESCRIPTION
To establish a new user on Plan 9, add the user's name to /adm/users by running the newuser command on the console of the file server (see users(6) and fs(8)). Next, give the user a password using the changeuser command on the console of the authentication server (see auth(8)). At this point, the user can bootstrap a terminal using the new name and password. The terminal will only get as far as running rc, however, as no profile exists for the user. The rc(1) script /sys/lib/newuser sets up a sensible environment for a new user of Plan 9. Once the terminal is running rc, type rc /sys/lib/newuser to build the necessary directories in /usr/$user and create a reasonable initial profile in /usr/$user/lib/profile. The script then runs the profile which, as its last step, brings up 81/2(1). At this point the user's environment is established and running. (There is no need to reboot.) It may be prudent at this point to run passwd(1) to change the password, depending on how the initial password was cho- sen. The profile built by /sys/lib/newuser looks like this: bind -a $home/bin/rc /bin bind -a $home/bin/$cputype /bin font = /lib/font/bit/pelm/euro.9.font switch($service){ case terminal prompt=('term% ' ' ') fn term%{ $* } exec 81/2 case cpu bind -b /mnt/term/mnt/81/2 /dev prompt=('cpu% ' ' ') echo -n $sysname > /dev/label fn cpu%{ $* } news case con prompt=('cpu% ' ' ') news } Sites may make changes to /sys/lib/newuser that reflect the properties of the local environment. Use the -c option of mail(1) to create a mailbox. SEE ALSO
passwd(1), 81/2(1), namespace(4), users(6), auth(8), fs(8) NEWUSER(8)
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy