Automated password change from within shell script.

Automated password change from within shell script.

Post by ep-bayan » Thu, 21 Aug 1997 04:00:00



Hi,

I want to be able to change user-passwords from withing a shell-script.
I tried the standard passwd program but was unable to redirect the
interactive keyboard driven password change mechanism to read the new
passwords from a file.
Is there some "passwd" program or shell script around that enables you to
supply the new password on the command line ?
We run Solaris 2.4 on multiple SS5's.

Thanks,
Pieter Boeykens
Bayer Antwerpen.

 
 
 

Automated password change from within shell script.

Post by Andrew Pitm » Thu, 21 Aug 1997 04:00:00


: Hi,

...

: Is there some "passwd" program or shell script around that enables you to
: supply the new password on the command line ?


output of the w and ps commands, remember, so I doubt it.  Wouldn't
be hard to write one, though.    

: Thanks,
: Pieter Boeykens
: Bayer Antwerpen.

Andrew

--
                              MVRDOCK
               - QVANTVLA SAPIENTIA REGITVR MVNDVS -

+-------------------------------------------------------------------+
|                    Unix System Administrator                      |
|                    ^^^^^^^^^^^^^^^^^^^^^^^^^                      |
| "You can't hate yourself in the morning if you sleep 'till noon." |
+-------------------------------------------------------------------+

 
 
 

Automated password change from within shell script.

Post by Michael Keuker » Thu, 21 Aug 1997 04:00:00



> Is there some "passwd" program or shell script around that enables you to
> supply the new password on the command line ?

If you download the "shadow" source package and compile it manually,
then youll find the program chpasswd which does the desire task. The
program reads a pair of username/password from stdin and is even able to
do mass-updates.

Within a shellskript, you can use it like this:

echo $user:$password | chpasswd

--
Michael Keukert, International Sales & Marketing Manager
SCP GmbH, Auf der Hls 120, D-52068 Aachen, Germany
Phone: ++49-241-96830-0
Fax  : ++49-241-96830-50
http://www.scp.de

 
 
 

Automated password change from within shell script.

Post by Wanli M » Sat, 23 Aug 1997 04:00:00



> output of the w and ps commands, remember, so I doubt it.  Wouldn't
> be hard to write one, though.

No, not so easy! "passwd" is deliberately coded to accept input ONLY
from keyboard. You've got to play some tricks to get around it ;-)

cheers,
wanli

 
 
 

Automated password change from within shell script.

Post by Rick Norwoo » Sat, 23 Aug 1997 04:00:00




> > output of the w and ps commands, remember, so I doubt it.  Wouldn't
> > be hard to write one, though.

> No, not so easy! "passwd" is deliberately coded to accept input ONLY
> from keyboard. You've got to play some tricks to get around it ;-)

> cheers,
> wanli

So why not just use the crypt function call in a small c, perl, ...
program.  This is done fairly easily.  Then all you would have to
do is specify the user names and let the program change the
program change the password.

Here is a little snip-it of code a friend of mine wrote that will
generate a random password for some user.

#
# Rnd_passwd creates a random password for for the new user.
#
sub Rnd_passwd {
   local $rndpass;
   local $thispass;
   local $lttrs;
   local $pwlen, $rndp, $rndp2;
   $pwlen = 8;
   $thispass = ' ' x 8;
   $rndpass  = ' ' x 8;
   $lttrs = "abcdefghjklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789";
   $puncs = "#!.+-";

   srand(time|$$);
   $rndp2 = int(rand($$));
   srand(time|$rndp2);
   $rndp = int(rand(length($puncs)));
   $thispass=substr($puncs,$rndp,1);
   srand(time|$$);
   for ($i=1; $i< $pwlen; $i++)
     {
      $rndp = int(rand(length($lttrs)));
                substr($thispass,$i,1) = substr($lttrs,$rndp,1);
     }
   $rndp = int(rand(pwlen-2))+1;
   $rndp2 = int(rand(length($puncs)));
   substr($thispass,$rndp,1) = substr($puncs,$rndp2,1);
   $rndpass = crypt("$thispass","$puncs");
   return ($rndpass,$thispass);

Quote:}

Rick

--
----------------------------------------------------------------------
||   Richard Norwood (SGI)      | "We have not inherited the Earth  ||
||   GWIS/Technical Consultant  |  from our ancestors."        ||
||                              |                                   ||
||   Phone:  (301)-572-3296     | "We have only borrowed it from    ||

||   Beeper: 1-800-792-7933     |         - Ancient Proverb         ||
||   Alpha Pager:               |                                   ||

----------------------------------------------------------------------

 
 
 

Automated password change from within shell script.

Post by Jim Bac » Sat, 23 Aug 1997 04:00:00




: > output of the w and ps commands, remember, so I doubt it.  Wouldn't
: > be hard to write one, though.
: >

: No, not so easy! "passwd" is deliberately coded to accept input ONLY
: from keyboard. You've got to play some tricks to get around it ;-)

I suppose it's time to mention one word:
        expect
--
Jim Bacon (JB211), SysAdmin          Metropolitan Austin Interactive Network

"You deal with content and humans, I deal with reality."
                                        -- A Sysadmin talking to a Webmaster
-... --- ..-. ....

 
 
 

Automated password change from within shell script.

Post by Joe Reut » Wed, 03 Sep 1997 04:00:00



>No, not so easy! "passwd" is deliberately coded to accept input ONLY
>from keyboard. You've got to play some tricks to get around it ;-)

Actually, "passwd" accepts it input from the terminal, else how could
it work for a telnet session.  Don Libes' "expect" gets around that
limitation fairly easily!
--
Joseph A. Reuter, Wizard-in-Training, speaking for myself alone

"Olorin I was in my youth in the West that is forgotten."--J. R. R. Tolkien
 
 
 

Automated password change from within shell script.

Post by Dennis DiPasqua » Thu, 04 Sep 1997 04:00:00


: : Is there some "passwd" program or shell script around that enables you to
: : supply the new password on the command line ?


: output of the w and ps commands, remember, so I doubt it.  Wouldn't
: be hard to write one, though.    

I've actually wrestled with this problem before... In an academic environment,
adding 100 or more students can become a pain...

Unless you directly encrypt the password into the shadow file, I don't believe
that it is possible.

However, to get around the security problem, one could execute such a script
while in single user mode. No one could execute a ps or w to snoop passwords.

and hey, if you do know a way, then please let me know :)

        -Dennis

--------------------------------------------------------------------------

College of Engineering                           Rowan University, NJ, USA
http://www.rowan.edu/~dipasqua                             +1 609.256.4742

 
 
 

Automated password change from within shell script.

Post by Matus Uhl » Fri, 05 Sep 1997 04:00:00



-> Hi Dennis.  :)

is this public group or what ?

-> Isn't there a way to have a C program rewrite it's *argv[]?
-> I think I remember hearing about something like that.      

not a problem but only /usr/ucb/ps sees that...
--
 Matus "fantomas" Uhlar, sysadmin of one server at SANET Kosice, Slovakia

 And don't forget: I work for SANET, but talk for myself, dude... ;-)

 
 
 

Automated password change from within shell script.

Post by Alva » Sat, 06 Sep 1997 04:00:00




>: : Is there some "passwd" program or shell script around that enables you to
>: : supply the new password on the command line ?


>: output of the w and ps commands, remember, so I doubt it.  Wouldn't
>: be hard to write one, though.    

>I've actually wrestled with this problem before... In an academic environment,
>adding 100 or more students can become a pain...

>Unless you directly encrypt the password into the shadow file, I don't believe
>that it is possible.

>However, to get around the security problem, one could execute such a script
>while in single user mode. No one could execute a ps or w to snoop passwords.

>and hey, if you do know a way, then please let me know :)

There is a passwd perl script in the Perl Camel book.
This would be easy to modify to accept command line input.

A better idea would be to put your usernames and passwords in a file
and then
        cat file | my_passwd_script

This avoids the paswords showing up on ps and w.

Alvaro.

 
 
 

Automated password change from within shell script.

Post by Fiji » Tue, 09 Sep 1997 04:00:00





> >: : Is there some "passwd" program or shell script around that enables you to
> >: : supply the new password on the command line ?


> >: output of the w and ps commands, remember, so I doubt it.  Wouldn't
> >: be hard to write one, though.

you could easily write one using an expect script.

-Fiji

 
 
 

Automated password change from within shell script.

Post by Frank Pard » Wed, 26 Nov 1997 04:00:00


Look at the "expect" package: http://expect.nist.gov/


> Hi,

> I want to be able to change user-passwords from withing a shell-script.
> I tried the standard passwd program but was unable to redirect the
> interactive keyboard driven password change mechanism to read the new
> passwords from a file.
> Is there some "passwd" program or shell script around that enables you to
> supply the new password on the command line ?
> We run Solaris 2.4 on multiple SS5's.

> Thanks,
> Pieter Boeykens
> Bayer Antwerpen.


--
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  ~    "Chi fila ha una camicia e chi non fila ne ha due."    ~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
 

1. Automated password change from within shell script.

Hi,

I want to be able to change user-passwords from withing a shell-script.
I tried the standard passwd program but was unable to redirect the
interactive keyboard driven password change mechanism to read the new
passwords from a file.
Is there some "passwd" program or shell script around that enables you to
supply the new password on the command line ?
We run Solaris 2.4 on multiple SS5's.

Thanks,
Pieter Boeykens
Bayer Antwerpen.

2. crypt(3) source code

3. shell script within shell script (general question)

4. Recovering a deleted file.

5. Changing the password from within a script

6. Starting Linux Software RAID 1 on /boot after disk failure...

7. Changing directories within a bash shell script

8. P-Mail <-> Internet gateway?

9. Changing user within shell script

10. Change standard output within a shell script

11. How to change passwords from C program or shell script?

12. unix shell commands within ftp shell script

13. Change user password using shell script