03-04-2012 08:18 PM - edited 03-04-2012 09:22 PM
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.
03-04-2012 11:51 PM
Maybe this can hep you:
You will possibly need to modify it a bit to match your exact needs.
03-05-2012 01:23 AM
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.
03-07-2012 07:14 AM
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.
03-09-2012 11:32 PM
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>
/usr/sbin/useradd -m -p '<encrypted_password_here>' newuser
/user/lbin/modprpw -v newuser ====> to reset aging password to zero
03-28-2012 09:37 AM
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 .