It is currently Sat, 24 Oct 2020 08:46:50 GMT



 
Author Message
 Howto set passwords via script?
Hi,
I have to setup many user accounts on a Solaris 7 machine.
I want to give each user an individual initial password.
Is there a way to do this via a script?
My problem ist that passwd asks interactively for the password and does not
accept input from stdin for the password.

Thanks Frank



 Tue, 14 May 2002 03:00:00 GMT   
 Howto set passwords via script?

Don't know if this is exactly the same under all unix variants or not (Don't
have much Solaris experience personally), but here is a trick I use under
similar circumstances sometimes. I believe passwd does not take input from a
pipeline because it flushes stdin or something to that effect before reading
the input. But you can get around it by doing something like this:

#!/bin/sh
(
usleep 100
echo "Newpassword"
usleep 100
echo "Newpassword"
) | passwd insert_username_here

This assumes that you are running as root so it doesn't ask for the old
password. You may be able to get by with shorter usleeps or you may have to
lengthen them, but the general idea is to delay the password going into the
stdin of the passwd command until after it has already flushed the buffer.
There are undoubtedly better ways to get this done, but this is a quick and
dirty way that gets the job done without having to install any external
utilities like expect or anything, which can be a hassle, particularly on a box
without a c compiler.

Shawn Asmussen



 Wed, 15 May 2002 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Howto set the password by command line

2. CGI script for changing passwords via WWW

3. Changing password via script

4. I am looking for a way to update passwords via program or script

5. changing password via shell script

6. Howto set an environment var in shell script?

7. Howto set an environment var in shell script?

8. Can't set root password- Password busy error -is not due to temp password file

9. Setting The Clock Via NTP (was: Shell Scripting Flexibility


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software