How can I set passwords from script/file?

How can I set passwords from script/file?

Post by Steve Rosem » Wed, 15 May 1991 04:51:53



Does anyone have a good way of setting user passwords from a file, script,
etc.?  Running "passwd username <file" gives a "Must run from tty" error
message.  I need this capability for administrative mass password setting, and
changing the user interface for passwd (not my idea.)

Thanks,
Steve

-------------------------------------------------------------------------
Steve Roseman
Lehigh University Computing Center

 
 
 

How can I set passwords from script/file?

Post by Jose Angel Vela Avi » Wed, 15 May 1991 13:11:24



>Does anyone have a good way of setting user passwords from a file, script,
>etc.?  Running "passwd username <file" gives a "Must run from tty" error
>message.  I need this capability for administrative mass password setting, and
>changing the user interface for passwd (not my idea.)

 You could use expect for do anything you want from a interactive process..

 All this in a script of course ....

 If you need more information, drop me an email...

Jose A. Vela A.


 
 
 

How can I set passwords from script/file?

Post by Hugo Calend » Wed, 15 May 1991 22:18:47



>Does anyone have a good way of setting user passwords from a file, script,
>etc.?  Running "passwd username <file" gives a "Must run from tty" error
>message.  I need this capability for administrative mass password setting, and
>changing the user interface for passwd (not my idea.)

You could try writing some C code to alter the /etc/passwd file, or
use some C in conjunction with awk or something.  Use the "crypt()"
function to generate password encryptions, (see man crypt).  If you
don't get my drift, mail me, and I'll send you something workable.

Hugo

 
 
 

How can I set passwords from script/file?

Post by Mike Cud » Fri, 17 May 1991 08:52:34



>Does anyone have a good way of setting user passwords from a file, script,
>etc.? ...
>Steve Roseman
>Lehigh University Computing Center


I use this little program: (I call setpass.c) I think that this is even the
'right' way to do this. (mind ya', you'll have to get you're own password
encrypting function (Std. unix alg.)  I grabbed some stuff off of
comp.sources.unix a couple of months ago.

---snip-da-do ---snip-da-do ---snip-da-do ---snip-da-do
#include <stdio.h>
#include <userpw.h>
#include <usersec.h>

main(argc,argv)
int argc;
char **argv;
{
    struct userpw *pw;

    if (argc < 2 || argc > 3) {
        fprintf(stderr,"Usage: setpass <user> [<encrypted-password>]\n");
        exit(1);
    }

    if (setpwdb(S_READ|S_WRITE) < 0) {
        perror("setpass: setpwdb"); exit(1);
    }

    if ((pw = getuserpw(argv[1])) == NULL) {
        perror("setpass: getuserpw"); exit(1);
    }

    if (argc == 2) {
        printf("%s\n",pw->upw_passwd); exit(0);
    }

    pw->upw_passwd = argv[2];

    pw->upw_flags |= PW_ADMCHG;
    pw->upw_lastupdate |= time(0);

    if (putuserpw(pw) < 0) {
        perror("setpass: putuserpw"); exit(1);
    }

    if (endpwdb() < 0) {
        perror("setpass: endpwdb"); exit(1);
    }

    exit(0);

Quote:}

---snip-da-do ---snip-da-do ---snip-da-do ---snip-da-do
--Mike Cuddy
"...He's a UNIX hack and he's okay, he works all night and he sleeps all day..."
Well, where I come from, we have a saying: "If you're not going to grab the
bull by the horns while the iron is in the fire, then get off the pot."
(There are a lot of chemicals in the water where I come from.) -- Dave Barry
 
 
 

1. Network passwords (was Re: How can I set passwords from script/file?)

The Novell network has support for synchronizing passwords across all
servers whenever a user sets the password on any one of them.

I have an environment which consists of several dissimilar Unix systems
on a TCP/IP network; AIX is the main "server".  Is there a reasonable
way to propagate passwords to other systems whenever a user sets the
user account password on one of them?  Presumably, SCO and IBM use
different hashing schemes for passwords, and they both go to some trouble
to make the password-setting operation difficult.

As things stand, it's hard for me to imagine having a secure network,
because users will tend to leave their passwords as simple as possible
for long periods on various systems, leaving the system open for password-
hacking.  Forcing them to change their password on a monthly basis would
be nice, but impractical if they have to log into every system (some
of which are used infrequently) to do so.

-rich

2. socket, select(), help

3. Can't set root password- Password busy error -is not due to temp password file

4. libc5->glibc2... now can't unmount /usr

5. Setting a password from a script file

6. UseNet in AIX

7. setting user password from script file

8. xdm background

9. Converting old-style password file to new password/shadow file

10. expect scripts and setting passwords

11. Setting passwords in a script

12. Set user password by script ?