SUMMARY: setting initial passwords

From: Muralinath Pala (
Date: Thu Feb 01 1996 - 09:03:44 CST

I'm just overwhelmed at the number of responses i've been getting (inspite
of my previous SUMMARY). So, i'm forced to send an updated summary, as lot of
folks seem to be interested in it.

The most popular solution seems to be the 'expect' program, closely followed
by 'perl' scripts.

I'm including here some of the most informative responses.


--Muralinath Pala

>From Thu Feb 1 09:18 EST 1996
Date: Thu, 1 Feb 96 08:25:40 -0600
From: (Mario Nonino)

   I think you could use
   You can ftp it from

   In the book
   Exploring Expect ,
   O'Reilly & A. by Don Libes
   the very first example is your problem!.

>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

  -- Mike

#!/usr/local/bin/expect -f
spawn passwd [lindex $argv 0]
expect "New password:"
send "[lindex $argv 1]\r"
expect "Re-enter new password:"
send "[lindex $argv 1]\r"

>From Wed Jan 31 17:39 EST 1996
Date: Wed, 31 Jan 1996 16:56:59 -0600 (CST)
From: Kent R Arnott <>

        use something like this


>From Wed Jan 31 13:33 EST 1996
From: Matthew Ball <>

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.

This is all based on the crypt sub-routine (man -s 3 crypt).

/* mkpasswd.c */

#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]);

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