* Matthew Alton <Simplicissimus-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx>
[2006-03-30 18:06]:
> Hiya folks,
>
> I routinely use a utility called "chpasswd" on AIX and Red Hat Linux.
> I sure would like to use this utility on Solaris but it does not exist
> and I can't seem to find a reasonable alternative. I'll write the
> danged thing if I have to. Do I have to? Enquiring minds want to
> know.
>
> Here the spec. Syntax: chpasswd [ -e | -h ]. Pretty simple stuff in
> theory. The "e" switch tells the program that we are passing it an
> already encrypted password, so use it verbatim, otherwise we use
> crypt(3) on "password." The "h" switch get you the usage blurb. The
> program simply reads "username:password" pairs from stdin and changes
> the system password of "username" to "password" of all things. The
> glory of the thing is that it is scriptable so you can do cute things
> like "cat foo.txt | chpasswd" and no, it won't work with "passwd"
> because that program makes sure you're not piping to it. I'm truly
> not interested in PAM and NIS. If I write this thing, it's going to
> lock and alter /etc/passwd and /etc/shadow and call it a day. No root
> UID? Whine & fail. Frankly, I find PAM somewhat less than
> comprehensible.
>
> I've found the "shadow" stuff and the CGIpaf and a few others. These
> will provide reference material but not much else. Is there a true
> chpasswd for Solaris?
>
> I'm going to write the thing, amn't I? Well, when I do, I'll post it
> here. That'll do some good, right?
As far as I know, we don't have chpasswd in OpenSolaris. The
PAM/passwd folks will definitely know--they will be listening in the
Security community, if they aren't watching here.
You can also submit a bug to the bug database, so that the whole
community. See
http://bugs.opensolaris.org
(You must be a registered user to submit a bug.)
- Stephen
--
Stephen Hahn, PhD Solaris Kernel Development, Sun Microsystems
stephen.hahn-xsfywfwIY+M@xxxxxxxxxxxxxxxx http://blogs.sun.com/sch/
chpasswd Jan 16, 2007 2:39 AM
Hi All
does sun have an equivalent to the chpasswd in linux?
|
mAbrante
Posts:1,595
Registered: 8/19/05
Re: chpasswd
Jan 16, 2007 3:26 AM (reply 1 of 6)
Not as such (at least not that i know of). But its probably an quite
easy script to write. As an alternative you can edit the /etc/passwd
file manually or use usermod.
.7/M.
Re: chpasswd
Jan 17, 2007 12:43 AM (reply 2 of 6)
yip but with chpasswd you can use excel to import all the users names
then put in a password and copy down for the 1000 users and run it through
the command and all the passwords are changed.
really great when you are installing a system and have setup the users
now have to setup a specific password for the users.
mAbrante
Posts:1,595
Registered: 8/19/05
Re: chpasswd
Jan 17, 2007 5:49 AM (reply 3 of 6)
Can't you just copy the passwd/shadow files from another system in that
case? Or implement a namingservice.
.7/M.
Re: chpasswd Jan 17, 2007 1:50 PM (reply 4 of 6)
what does chpasswd do said the non lnux person. alan
mAbrante
Posts:1,595 Registered: 8/19/05
|
Re: chpasswd Jan 18, 2007 6:44 AM (reply 5 of 6)
Relevant question. A person i know who have a linux box sent me the
following extract from the manpage. NAME chpasswd - update password file in batch SYNOPSIS chpasswd [-e]
DESCRIPTION chpasswd reads a file of user name and password pairs from standard input and uses this information to update a group of existing users. Without the -e switch, the passwords are expected to be cleartext. With the -e switch, the passwords are expected to be in encrypted form. Each line is of the format user_name:password
The named user must exist. The supplied password will be encrypted as necessary, and the password age updated, if present. This command is intended to be used in a large system environment where many accounts are created at a single time. .7/M.
Re: chpasswd Jan 18, 2007 1:13 PM (reply 6 of 6)
I've never heard of anything like this for Solaris. Even a naming service
doesn't fit the bill as they still require you to enter the passwords,
clear text, by hand, and then they are converted to some hash. You could try compiling chpasswd on Solaris, or if it's a script file,
you could just try running the script. A test box would be great for
this endeavor.
If not, then it sounds like you could write some code that parses a
filenowadays.
Looks like you're going to need a coder for this one. alan
Changes password for users.
chpasswd [
-R load_module ] [
-e ] [
-f flags |
-c ]
The chpasswd command administers users' passwords.
The root user can supply or change users' passwords specified through standard
input. Each line of input must be of the following format.
username:password
Only root users can set passwords with this command.
By default, the chpasswd command sets the ADMCHG
flag for the users. The -f option may be used with
other valid flags to override the default. The -c
option clears all password flags.
The password field can be cleartext or a value encrypted with the crypt
algorithm. The -e option indicates that passwords
are of encrypted format. Please note that all passwords in a batch must
conform to the same format.
Flags
|
-c |
Clears all password flags. |
|
-e |
Specifies that the passwords are of encrypted format. |
|
-f flags |
Specifies the comma separated list of password flags to
set. Valid flag values are: ADMIN, ADMCHG, and/or NOCHECK. Refer
to the pwdadm command documentation
for details about these values. |
|
-R load_module |
Specifies the loadable I&A module used to change users'
passwords. |
Security
Access Control: Only root users should have execute
(x) access to this command. The command should have the trusted computing
base attribute.
Examples
- To set passwords for users from the command line, type:
chpasswd Followed by entering
username:password pairs, one
pair per line. Enter CTRL+D when finished.
user1:passwd1
user2:passwd2
CTRL+D
- To set passwords for users contained in a file named
mypwdfile, type the following:
cat mypwdfile | chpasswd
Note that mypwdfile must contain
username:password pairs; one pair per line. For
example:
user1:passwd1
user2:passwd2
...
Files
| Mode |
File |
Description |
| |
/etc/user/bin/chpasswd |
Location of the chpasswd
command. |
| rw |
/etc/passwd
|
|
| rw |
/etc/security/passwd |
|
| r |
/etc/security/user |
#!/usr/local/bin/expect -- # wrapper to make passwd(1) be non-interactive # username is passed as 1st arg, passwd as
2nd # Executable only by root
set password [lindex $argv 1] spawn /usr/bin/passwd [lindex $argv 0] expect "password:" send "$password\r" expect "password:" send "$password\r" expect eof
But when I run it, it still prompted the line
"Retype new Unix password". How can I run it without the above line?
Pls. recommend me Thank you so much
|
|
Have you looked at using usermod instead of passwd?
Are you using passwd because this is a homework
assignment?
man usermod
|
|
#!/bin/bash
# Script to update user password in batch mode
# You must be a root user to use this script
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version
2.0 or above # -------------------------------------------------------------------------
# This script is part of nixCraft shell script
collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# /root is good place to store clear text password FILE="/root/batch.passwd" # get all non-root user account
# By default on most linux non-root uid starts
# from 1000 USERS=$(awk
-F:
'{ if ( $3 >1000 ) print $1}'
/etc/passwd) # create file with random password
echo "Generating
file, please wait..."
# overwrite file
>$FILE for u in
$USERS do p=$(pwgen
-1
-n 8)
# create random password
echo "$u:$p"
>> $FILE
# save USERNAME:PASSWORD
pair done echo
""
echo "Random password
and username list stored in $FILE file"
echo "Review $FILE
file, once satisfied execute command: "
echo "chpasswd
< $FILE"
# Uncomment following line if you want immediately
update all users password, # be careful with this option, it is recommended
that you review $FILE first # chpasswd < $FILE
In case of broken links
please try to use Google search. If you find the page please notify
us about new location
Copyright © 1996-2009 by Dr. Nikolai Bezroukov.
www.softpanorama.org was
created as a service to the UN Sustainable Development Networking Programme (SDNP)
in the author free time.
Submit
comments This document is an industrial compilation designed and created
exclusively for educational use and is placed under the copyright of the
Open Content License(OPL).
Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made
for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
- The statements, views and opinions presented on
this web page are those of the author and are not endorsed by, nor do they necessarily
reflect, the opinions of the author present and former employers, SDNP or any other
organization the author may be associated with.
- We do not warrant the correctness of the information provided or its
fitness for any purpose
- In no way this site is associated with or endorse cybersquatters
using
the term "softpanorama" with other main or country domains (e.g. softpanorama.com) with
bad faith intent to profit from the goodwill belonging to
someone else.
Created: May 16, 1997; Last modified:
August 08, 2009
|