Operating System - HP-UX
1748128 Members
3456 Online
108758 Solutions
New Discussion юеВ

Re: script to create new user and set a password

 
itrc55
Regular Advisor

script to create new user and set a password

Hi,

 

i have more than 150 servers, please i need a script to create new user and set a password, where i can't login to each server to set password. i have a tools to push and run this script on all servers. but only i need this script.

 

And all system on trusted mode  and OS is HP-UX 11.31.

 

i don't need interactive script because i want to push it to all user to create specific user with specific password

 

your support please.

 

 

Thanks

6 REPLIES 6
VK2COT
Honored Contributor

Re: script to create new user and set a password

Hello,

 

Maybe this can hep you:

 

http://www.circlingcycle.com.au/Unix-sources/add-batch-Unix-accounts.pl.txt

 

You will possibly need to modify it a bit to match your exact needs.

 

 

VK2COT - Dusan Baljevic
itrc55
Regular Advisor

Re: script to create new user and set a password

Hi,

 

thanks for your support, but i need a simple scripts if you have, when i try to modify this script will take more time.

i am not a good to write scripts.

 

thanks agin.

itrc55
Regular Advisor

Re: script to create new user and set a password

Hi,



please any help, your support.



Thanks
Matti_Kurkela
Honored Contributor

Re: script to create new user and set a password

Actually, you don't need a script. You just need to run one command in each host to create the user. But first you'll need to generate an encrypted (actually hashed) password for the new user.

 

An encrypted password can be created using the "openssl passwd" command:

$ openssl passwd -crypt
Password: <type the password here> 
Verifying - Password: <type the password again here>
<encrypted_password_here>

If you run this command again and type the same password, you will get a different encrypted password string each time. This is normal.

 

 

Once you have the password in encrypted form, you can build the command for creating the user account.

The command to create an account "jluser" for John L. User would be:

/usr/sbin/useradd -c 'John L. User' -m -p '<encrypted_password_here>' jluser

Run "man useradd" and read to find out what the options mean.

 

NOTE: since the encrypted password may contain characters that have a special meaning to the shell, you should use single quotes around it, exactly as in the example above. The single quotes are the "strongest" quotes available in any common Unix shell.

 

NOTE 2: the encrypted password generated by "openssl passwd -crypt" is a bit weak: with modern computers, it is too easy to check a large dictionary of words and find the original password that matches a given encrypted password. But it is the only form of encrypted password that is acceptable for all HP-UX 11.31 password configurations: traditional Unix mode, the deprecated Trusted System Mode, and the Shadow Password mode.

 

NOTE 3: read the documentation of your command-pushing tool and see if it treats any characters specially. If it does, and your encrypted password string contains one of the special characters, you may need to do something to tell the command-pushing tool to not apply the special meaning of the character in the encrypted password. If your command-pushing tool is any good, it should be able to do this.

MK
itrc55
Regular Advisor

Re: script to create new user and set a password

Hi,

thanks for your support, i run the below commands on each servers.

$ openssl passwd -crypt
Password: <type the password here>
Verifying - Password: <type the password again here>
<encrypted_password_here>

/usr/sbin/useradd -m -p '<encrypted_password_here>' newuser

/user/lbin/modprpw -v newuser ====> to reset aging password to zero

Thanks
Sachin Rajput
Advisor

Re: script to create new user and set a password

So are you happy with the above solution ..

I think if you put that in a loop to run on all the servers . you will need to give password for each server two times .

If you want to avoid entering the passwd everytime instead specify command line . YOu can use expect ..

If need any help related to expect let me know .

Sachin Rajput
=============


Sachin Rajput
================