SUMMARY: setting initial passwords

From: Muralinath Pala (
Date: Wed Jan 31 1996 - 16:28:32 CST

I thank all those sent in their replies, especially Matthew Ball, 'cause
i ended up using his solution.

--Muralinath Pala.

Original Post

> I'm in the process of creating some 1000+ new users on our system.
> I have a list of initial passwords for these users (each user having
> a unique initial passsword). I already have a script to create the users
> with a null password. The question is, How do i automate the process of
> setting the initial passwords for these users? All my attempts to use
> 'passwd' in the script with input from the list of passwords have been
> futile. May be i'm missing somethings here.
> I would appreciate it if someone could help me with this ( shell script
> or C routine). Please email me directly, as i don't have access to this
> mailing list.
> Thanks.


Solution Summary
From: Matthew Ball <>
Date: Wed, 31 Jan 1996 18:38:31 GMT

Try this, a little C programme I just knocked up!

   mkpasswd string
It then echoes an encrypted passwd suitable for an /etc/passwd or /etc/shadow


   mkpasswd < file_of_strings > file_of_passwd

encrypt a file of strings into passwords in one go.
#include <stdio.h>
#include <string.h>

int argc;
char *argv[];
  char line[512],salt[3];
  int i,l;


  if(argc == 1) /* No parameters there read from standard input */
    while(gets(line) != NULL)
      if(l > 2)
        fprintf(stderr,"Too short [%i] \"%s\"\n",l,line);
      if(l > 2)
        fprintf(stderr,"Too short [%i] \"%s\"\n",l,argv[i]);
--------------------END mkpasswd.c-----------------------------------
This is all based on the crypt sub-routine (man -s 3 crypt).

Hope it helps!


Other Replies

Date: Wed, 31 Jan 1996 13:18:42 -0600

use expect : a tcl application which is able to redirect and feed 'tty'
There was a paper on USENIX many years ago.

for the location, use archie.

>From Wed Jan 31 16:02 EST 1996
Date: Wed, 31 Jan 1996 16:08:46 -0500
From: (Mike Jipping)

The "passwd" command wants I/O directly from user and bypasses redirection.
You need a program called "expect" that is designed for this. Expect does
user banter well, and I include below a little password script that works for

>From Wed Jan 31 16:50 EST 1996
Date: Wed, 31 Jan 1996 16:56:38 -0500
From: Chris Eastman <>

the crypt function is used to create the passwd field entry, all you
would have to do is have your program pipe the password to crypt, then
return the results in the form of a variable to be used with your shell
script. I don't currently have the crypt command on this machine, but if
I am not mistaken crypt.c is in the shared libs for libc - I need to
write the same program, mail me again if you still need help and I will
write it up - otherwise send me your solution. :)

>From Wed Jan 31 17:04 EST 1996
Date: Wed, 31 Jan 1996 17:11:06 -0500 (EST)
From: Zhiyi Huang <>

For Solaris 2.x:
  passwd -d -f -x 180 -n 0 -w 14 $user

will do it. Where $user is the new user's login name.


This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:52 CDT