how do I (non-interactively) change a users password in a script ?
/bin/sh script. Need to change a users password within the script based on a file of user/pass I am feeding the script. Easy. Except the passwd command does not seem to be able to take a password as an argument - I don't think that the passwd command can run non-interactively. So how is this done ? It looks like the adduser script does it non-interactively somehow ... but I don't see how. Thanks. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: how do I (non-interactively) change a users password in a script ?
On Tue, Jan 17, 2006, user wrote: /bin/sh script. Need to change a users password within the script based on a file of user/pass I am feeding the script. See ``man pw'', in particular the ``-h fd'' option. .. Except the passwd command does not seem to be able to take a password as an argument - I don't think that the passwd command can run non-interactively. You can also use expect which is designed for just this sort of thing. Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX:(206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 ``Ah, you know the type. They like to blame it all on the Jews or the Blacks, 'cause if they couldn't, they'd have to wake up to the fact that life's one big, scary, glorious, complex and ultimately unfathomable crapshoot -- and the only reason THEY can't seem to keep up is they're a bunch of misfits and losers.'' -- A analysis of Neo-Nazis, from The Badger comic ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: how do I (non-interactively) change a users password in a script ?
user wrote: /bin/sh script. Need to change a users password within the script based on a file of user/pass I am feeding the script. Easy. Except the passwd command does not seem to be able to take a password as an argument - I don't think that the passwd command can run non-interactively. So how is this done ? It looks like the adduser script does it non-interactively somehow ... but I don't see how. Thanks. Yes, you can do this: -h fd This option provides a special interface by which interac- tive scripts can set an account password using pw. Because the command line and environment are fundamentally insecure mechanisms by which programs can accept information, pw will only allow setting of account and group passwords via a file descriptor (usually a pipe between an interactive script and the program). sh, bash, ksh and perl all pos- sess mechanisms by which this can be done. Alternatively, pw will prompt for the user's password if -h 0 is given, nominating stdin as the file descriptor on which to read the password. Note that this password will be read only once and is intended for use by a script rather than for interactive use. If you wish to have new password confir- mation along the lines of passwd(1), this must be imple- mented as part of an interactive script that calls pw. If a value of `-' is given as the argument fd, then the password will be set to `*', rendering the account inacces- sible via password-based login. Read more in man 8 pw. I'm also sure that there are examples out there as well if you search on Google, etc. -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]