 |
 |
Change password via shell
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
I need to batch change passwords.
How can it be done using shell.
Want to create a perl script that allows users to enter their old password... and a new one.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: May 2002
Status:
Offline
|
|
Try
/user/bin/passwd
That is the standard unix way of doing
it
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
I would advise against using that though, because it will not update your keychain password.. only your login, so you will run into problems, and many, many annoying password request windows
use the preference pane
and ya, passwd does exactly what your perl script would do
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Arizona
Status:
Offline
|
|
I strongly suspect (I haven't tried this) that using the Unix passwd command won't update the password on the user's Keychain at the same time, however.
This will mean the Keychain will still have the old password and won't open automatically at login (user will have to open it with old password the first time it gets used per login until the user changes it or creates a new keychain.)
I don't know if the Unix command line can access the keychain. I doubt it.
(Edit: 11011001 types faster than I do.)
BTW, if you are changing all these passwords yourself, a sudo -s (to root) before running passwd will let you change the password without entering the old one (definitely won't update the keychain password.)
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
Originally posted by 11011001:
I would advise against using that though, because it will not update your keychain password.. only your login, so you will run into problems, and many, many annoying password request windows
use the preference pane
and ya, passwd does exactly what your perl script would do
Users only connect via AppleShare, and shell.
So they never see the keychain stuff anyway.
It's for file storage.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Apr 2000
Status:
Offline
|
|
passwd user
Will work fine, but yeah, Keychain won't be updated. If that's a non-issue, passwd will work fine.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
Originally posted by Cipher13:
passwd user
Will work fine, but yeah, Keychain won't be updated. If that's a non-issue, passwd will work fine.
Thanks Cipher!
I personally don't use Keychain period. Especially on this box.
It's a file server. The only passwords I'm concerned with are the main password (shell, ftp, AppleShare) and Samba.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status:
Offline
|
|
sudo niutil -createprop . /users/$theUsername passwd "`openssl passwd $thePassword`"
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: May 2002
Status:
Offline
|
|
Hey gatorparrots
Will niutil also change the the keychain
password
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chile
Status:
Offline
|
|
Originally posted by gatorparrots:
sudo niutil -createprop . /users/$theUsername passwd "`openssl passwd $thePassword`"
can you explain that ?
right from ... . / users ... onwards
thx
|
:: frankenstein / lcd-less TiBook / 1GHz / radeon 9000 64MB / 1GB RAM / w/ext. 250GB fw drive / noname usb bluetooth dongle / d-link usb 2.0 pcmcia card / X.5.8
:: unibody macbook pro / 2.4 Ghz C2D / 6GB RAM / dell 2407wfp - X.6.3
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Originally posted by Sarc:
can you explain that ?
right from ... . / users ... onwards
thx
From the man page for niutil...
Code:
niutil lets you to do arbitrary reads and writes on the
given NetInfo domain. In order to perform writes, niutil
must be run as root on the NetInfo master for the
database, unless the -p, -P, or -u options are given. The
directory specified by path is separated by "/"s, similar
to the filesystem. The property names may be given in the
path using a "=", but will default to the property name
"name". For example, the following refers to a user with
the user ID 3.
"/name=users/uid=3"
The following shorter form would also be sufficient:
"/users/uid=3"
You may specify a numeric ID for the directory instead of
the string path.
...
-createprop domain path key [ val... ]
Create a new property in the directory path. key
refers to the name of the property; 0 or more prop-
erty values may be specified. If the named prop-
erty already exists, it's overwritten.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status:
Offline
|
|
Originally posted by Sarc:
can you explain that ?
right from ... . / users ... onwards
thx
sudo niutil -createprop . /users/$theUsername passwd "`openssl passwd $thePassword`"
This command arbitrarily assigns a user's password. We're saying, "with root privileges, use niutil to create a property in the default domain at this path: /users/theUsername under the property key passwd, using the results of openssl passwd thePassword" for the value to be inserted...
Basic niutil usage:
niutil -createprop [opts] <domain> <path> <propkey> [<val>...]
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2000
Status:
Offline
|
|
Originally posted by theory:
Will niutil also change the the keychain password
No, no it will not. What gatorparrots posted is exactly the same thing as using the 'passwd' command.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Hmm, interesting. Perhaps someone should add support to change the keychain password to passwd, if anyone can be bothered. The source for Security and passwd are both there 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|