SUMMARY: setting initial passwords

From: Muralinath Pala (palam@mailbox.ne.tpd.eds.com)
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.

Thanks.

--Muralinath Pala

*******************************************************************
>From nonino@sdss.fnal.gov Thu Feb 1 09:18 EST 1996
Date: Thu, 1 Feb 96 08:25:40 -0600
From: nonino@sdss.fnal.gov (Mario Nonino)

   Hi,
   I think you could use
   Expect.
   You can ftp it from ftp.cme.nist.gov

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

********************************************************************
>From jipping@cs.hope.edu Wed Jan 31 16:02 EST 1996
Date: Wed, 31 Jan 1996 16:08:46 -0500
From: jipping@cs.hope.edu (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
us.

  -- 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"
exit

**********************************************************************
>From karnott@falcon.tamucc.edu Wed Jan 31 17:39 EST 1996
Date: Wed, 31 Jan 1996 16:56:59 -0600 (CST)
From: Kent R Arnott <karnott@falcon.tamucc.edu>

hi
        use something like this
#!/usr/bin/perl
chop;
$pword=<STDIN>;

$salt=substr($pword,0,2);
$password=crypt($pword,$salt);
return($password);

**********************************************************************
>From matthewb@airport.bt.co.uk Wed Jan 31 13:33 EST 1996
From: Matthew Ball <matthewb@airport.bt.co.uk>

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

Syntax:
   mkpasswd string
It then echoes an encrypted passwd suitable for an /etc/passwd or /etc/shadow
file.

Alternatively

   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>

main(argc,argv)
int argc;
char *argv[];
{
  char line[512],salt[3];
  int i,l;

  salt[2]='\0';

  if(argc == 1) /* No parameters there read from standard input */
  {
    while(gets(line) != NULL)
    {
      l=strlen(line);
      if(l > 2)
      {
        salt[0]=line[2];
        salt[1]=line[1];
        printf("%s\n",crypt(line,salt));
      }
      else
        fprintf(stderr,"Too short [%i] \"%s\"\n",l,line);
    }
  }
  else
  {
    for(i=1;i<argc;i++)
    {
      l=strlen(argv[i]);
      if(l > 2)
      {
        salt[0]=argv[i][2];
        salt[1]=argv[i][1];
        printf("%s\n",crypt(argv[i],salt));
      }
      else
        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