set passwords in a script in solaris 9 and return
I have a script that adds a user to the solaris 9 system
I also have a random password generator so I can pass the password to the command but someone needs to hit return twice to set it, I want the script to set it for me so I don't have to hit return. As it is now after I add the user I set the password manually I don't want to do that I want the script to do that for me, How do I make this work |
What do you want the script to do?
Many cli programs that require a password have the option of passing the password as a parameter. For example useradd takes the -p flag followed by a string to add the password. If this is used you will not need to press return twice when the user account is set up. HTH |
I haven't done it on Solaris 9 but generally whenever you have an interactive program that waits for response to prompts the best thing to use is "expect".
I found this thread about expect for Solaris 9. http://compgroups.net/comp.unix.sola...all-sol/333544 |
send variable to expect
I have a user add script to add a user to Solaris 9 it does everything except set the password, I have a password generator in my script I want to set the generator to a variable and pass the variable to expect so I can set the password when adding the user.
|
Within expect you can use command line arguments passed in so for example using first argument from command line (e.g. same thing as $1 in a shell script):
set newpw [lrange $argv 0 0] whaterver... send $newpw |
You could create the hash yourself and then append a line (all 7 fields) to /etc/passwd . After all accounts are added run pwconv . If doing this I'd set the "must change at next login" option in the hash to force a change to the new and better hashes available in Solaris 9.
|
from password generator to expect for Solaris
what I want to do is this I have a password generator as seen below which is in my script. this works for linux because linux has the "-p" option to pass the password too during the run of the useradd command, but Solaris doesn't as seen below for linux which is actually 2 stages
Code:
password=`</dev/urandom tr -dc A-Za-z0-9 | head -c8` then take the "password" variable and send that to expect so I don't have to enter it manually. |
All times are GMT -5. The time now is 06:15 AM. |