Operating System - HP-UX
1834915 Members
2761 Online
110071 Solutions
New Discussion

Re: how to create or modify password to an new user account

 
NICOLAS pascal
Occasional Contributor

how to create or modify password to an new user account

Hi,
I would like do a script to create a new user account and a new password but I can not generate a password in my script.
Do you have any tips.
My server is on hp/ux 11.00 and 11.11
I am not under trusted mode.

cia
6 REPLIES 6
Ravi_8
Honored Contributor

Re: how to create or modify password to an new user account

Hi,

$passwd user
must ask for new password for the user

in your script

user=$1 (if you don't use shift)
...
..
..
passwd $user

must ask for pasword for the user
never give up
NICOLAS pascal
Occasional Contributor

Re: how to create or modify password to an new user account

thx, but that script is not interactive.
I would like enter that sequence :
creatuser $1 $2

where $1 is the login and $2 the password that I have choosen for the user.

James R. Ferguson
Acclaimed Contributor

Re: how to create or modify password to an new user account

Hi:

Have a look at the man pages (1M) for 'useradd'. Use this to create your new account. Use 'passwd' to create a password for the account which will have been created in a locked state.

Regards!

...JRF...
Bill Douglass
Esteemed Contributor

Re: how to create or modify password to an new user account

perl -e 'print crypt("password", "SA"), "\n";'

will encrypt password with salt SA. This returns an encrypted password in the same format used in /etc/passwd.

Create a new user using useradd, then replace the locked password with the one from the perl crypt functions.

Or, generate the entire password record yourself, and append it to /etc/passwd. Create any home directories in your script, and set appropriate ownership.

In any case, be very careful and cautious with this. Slipping up can corrupt or destroy your password file, and the consequences are not pretty.
twang
Honored Contributor

Re: how to create or modify password to an new user account

create user user_name to the system with a UID of 201 and a primary group of user_group.
# useradd -u 201 -g user_group user_name

change user_name's password:
# passwd user_name
John Meissner
Esteemed Contributor

Re: how to create or modify password to an new user account

I just wrote this script to create users and assign them passwords.

All paths lead to destiny