From: Ing. Silvia Beltran S. (
Date: Tue Aug 05 1997 - 12:23:19 CDT

Thanks Sun Managers,

Thanks for all the people that answered my question, They helped me a
The question was:
I want to automate the task of add users, I did a script that added the
specific line in the /etc/passwd, but I want to add the encripted
password also, Does somebody know the use of crypt ? The man pages just
tell me:
crypt key password
and I use for example: crypt jo LIkes9
the result is: !d"yp
and this is not a valid password .....
The answer was:

Compile this program and run it from the command line with the following

cc -o rpass rpass.c
rpass sspasswd
Where ss represents the salt and passwd represents the actual password.
This is modification of similar program posted on sun-managers mailing
/* Reverse with easy salt 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]);


Stephen Harris <>"The command line crypt program is not the
same as the crypt() function call."
Silvia: sorry, I was confusing the ideas.

Rich Snyder <> "There is also a Perl crypt function
that does the same thing if you prefer Perl."
Silvia: I prefer use the c program :)

Michal Dombrowski <> "Perhaps you could use the
standard Solaris tool named 'useradd'"
Silvia: But useradd doesn't add the password

Jim Harmon <> "First, built the line that will
include the passwd, leaving the "passwd" field = ",." And then tell the
new user to login, or instead, after creating this line, invoke "passwd"
as root and install your new passwd for the user with expect or some
other utility."
Silvia: Well, the users can take them mails just using a POP/client,
they can't do telnet to the server ( policy), the second option ...
sometimes I have to set up 100 emails (more or less), imagine the
slowness with passwd, third option ... I used expect with a script,but
when the program take the user 30, the program break I don't know why
but that happend.

Special Thanks for:

Kamal Kantawala <>
BCE User <>
Bob Bridgham <>
"Rich Snyder" <>
Javier Figueiredo <> (Peter M Allan)
John Birtley <>
Stephen Harris <>
Michal Dombrowski <>
Chris Marble <>
Jose Luis Delgado <>
Jim Harmon <> (Mike Carson)
Ada Chan <>
"Brion Leary" <>
Ian TCollins <>
Gerald Combs - Unicom Communications <>
"Alex Lattanzi" <> (Frank Pardo)
Jim McVey <>
John D Groenveld <>
Troy Wollenslegel <>
Tawanda Queen <>

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:00 CDT