Thanks for all the prompt response.
> Because of the system migration, I have to create a lot of
> users. This can easily be done by using useradd. The accounts
> created by useradd are locked until passwd is called to change
> the password.
> Unfortunately, I can't find a non-interactive way to
> change the password. It's a pain if I have to change
> the password manually.
> Is there any menthod that I can change the passwords of 300+ users
> with little pain?
I received valuable help from:
Kumara Swamy-WIPRO-NA <firstname.lastname@example.org>
Stefan Voss <email@example.com>
Stephen Harris <firstname.lastname@example.org>
and those I haven't received yet.
With the help from one of my colleague, I solve my problem by
writing a simple expect script. The env variables UNAME and UPASS
carry the username and password respectively.
set username $env(UNAME)
set password $env(UPASS)
spawn passwd $username
expect "New password:"
expect "Re-enter new password:"
Thanks again for all the valuable and prompt help ^_^
Kumara Swamy-WIPRO-NA <email@example.com> suggested the following:
You can copy /etc/passwd file from your old server to new server ,
which would have taken care .
in case you are migrating from Sunos to solaris , run pwconv
command on the target server after copying passwd file
which takes care of shadow, etc .
Stephen Harris <firstname.lastname@example.org> suggested the use of "expect"
Stefan Voss <email@example.com> gave me another summary.
the program in this SUMMARY might help you changing the passwords. In combi-
nation with awk or a shell script, it could work somehow. If it does not
work, Silvia (firstname.lastname@example.org) might know a solution.
----- Begin Included Message -----
>From email@example.com Tue Aug 5 19:57:12 1997
Date: Tue, 05 Aug 1997 11:23:19 -0600
From: "Ing. Silvia Beltrán S." <firstname.lastname@example.org>
Followup-to: "Ing. Silvia Beltrán S." <email@example.com>
Organization: Departamento de Soporte Técnico
X-Mailer: Mozilla 4.01 [en] (Win95; I)
Subject: SUMMARY: Crypt
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=us-ascii
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
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
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 */
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 <firstname.lastname@example.org>"The command line crypt program is not the
same as the crypt() function call."
Silvia: sorry, I was confusing the ideas.
Rich Snyder <email@example.com> "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 <firstname.lastname@example.org> "Perhaps you could use the
standard Solaris tool named 'useradd'"
Silvia: But useradd doesn't add the password
Jim Harmon <email@example.com> "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
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 <firstname.lastname@example.org>
BCE User <email@example.com>
Bob Bridgham <firstname.lastname@example.org>
"Rich Snyder" <email@example.com>
Javier Figueiredo <firstname.lastname@example.org>
email@example.com (Peter M Allan)
John Birtley <firstname.lastname@example.org>
Stephen Harris <email@example.com>
Michal Dombrowski <firstname.lastname@example.org>
Chris Marble <email@example.com>
Jose Luis Delgado <firstname.lastname@example.org>
Jim Harmon <email@example.com>
Mike.Carson@telos.com (Mike Carson)
Ada Chan <firstname.lastname@example.org>
"Brion Leary" <email@example.com>
Ian TCollins <firstname.lastname@example.org>
Gerald Combs - Unicom Communications <email@example.com>
"Alex Lattanzi" <firstname.lastname@example.org>
email@example.com (Frank Pardo)
Jim McVey <firstname.lastname@example.org>
John D Groenveld <email@example.com>
Troy Wollenslegel <firstname.lastname@example.org>
Tawanda Queen <email@example.com>
----- End Included Message -----
/ Wales K. F. Wong /\
/ ITU, Open University / /\ _______________ ______________
/ of Hong Kong / / / Phone /\ / Fax /\
/__________________________/ / /___2768 6532__/ /\ /__2762 7469__/ /\
\__________________________\/ \______________\/ \_____________\/
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
Never lose faith in your ability
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:00 CDT