Sponsored Content
Full Discussion: Solaris passwd script
Operating Systems Solaris Solaris passwd script Post 302528259 by click on Monday 6th of June 2011 08:04:55 PM
Old 06-06-2011
Solaris passwd script

Hello all,

Since Solaris passwd does not have --stdin option can you advise how to change the password for 30 users with a script. The password can be the same one. I`ve tried already echoing, xargs, cat and similar.

Thanks.

---------- Post updated at 04:04 AM ---------- Previous update was at 03:13 AM ----------

Done it, thanks to my colleagues for suggesting this Smilie

One bash script with
Code:
#!/bin/bash
USERS="bob john carry"
for user in $USERS;
do
echo "Changing password for" $user
./chpass.exp $user
done

One expect script called ./chpass.exp

Code:
#!/usr/local/bin/expect -f

set force_conservative 0  ;# set to 1 to force conservative mode even if
                          ;# script wasn't run conservatively originally
if {$force_conservative} {
        set send_slow {1 .1}
        proc send {ignore arg} {
                sleep .1
                exp_send -s -- $arg
        }
}

set username [lindex $argv 0]
set timeout -1
spawn passwd $username
match_max 100000
New Password: "
send -- "test1\r"
expect -exact "\r
Re-enter new Password: "
send -- "test1\r"
expect eof

And we`re golden.
This User Gave Thanks to click For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Passwd History in Solaris 8

How to set passwd history feature in Solaris 8 to stop users from using their old passwords? (4 Replies)
Discussion started by: amoorti
4 Replies

2. UNIX for Dummies Questions & Answers

Dont have the root passwd for Solaris 8

Hello chiefs :) I have a SUN Enterprise 250, running Solaris 8.5 - I have managed to be able to connect a dumb terminal to the box via a standard straight-through rj45 cable, to my ibm laptop. OK so Putty can connect to the box via ssh - nice! But I dont have the password for root - or any... (1 Reply)
Discussion started by: congo
1 Replies

3. UNIX for Advanced & Expert Users

change passwd remotely in solaris 10

i'm trying to change passwd remotely in unix (solaris) and tried using "expect" but it is not working. Any ideas to change the passwd remotely using a shell script? (1 Reply)
Discussion started by: pharos467
1 Replies

4. Solaris

solaris 8 passwd

Dear all, One one of the systems running solaris 8 the oracle account has a issue when trying to set the passwd. Following is what i get when the passwd command is executed. :/opt/oracle> passwd Enter existing login password: System configuration error. Please contact your administrator.... (1 Reply)
Discussion started by: earlysame55
1 Replies

5. Solaris

Solaris 8 passwd locked out − permission denied

Hi Gurus, i have ussers cannot change their passwords, neither can root change the user's password. O.S. Solaris 8 up−to−date on security patchaes as far as I know. Examples (names have been changed to protect the guilty): User logged on: $ passwd passwd: Changing password for <user>... (8 Replies)
Discussion started by: raziayub
8 Replies

6. Solaris

Solaris 10 allow ssh login with empty passwd

I have turned off PermitEmptyPasswords in sshd_config, but a user with empty passwd (deleted by passwd -d user) can still login without password, why? it is big security concern, linux doesn't have the issue. $ uname -a SunOS 5.10 Generic_118855-14 i86pc i386 i86pc ... (8 Replies)
Discussion started by: honglus
8 Replies

7. Solaris

Solaris passwd problem

Hi, I am using solaris 10. i am facing a strange problem regarding os passwd. i have a user oracle with passwd abc123 when i open a putty session with the os using abc123 it logs on. but if i use abc123!@# it agian log on without passwd error. I came to know about the issue that if i... (5 Replies)
Discussion started by: malikshahid85
5 Replies

8. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

9. Solaris

snmp trap for passwd file deltas in solaris

Hello I am trying to monitor when a user account gets added to my solaris server. Does anyone know how I can set up an snmptrap for changes in the /etc/passwd file ? (4 Replies)
Discussion started by: prince2010
4 Replies

10. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies
CHPASS(1)						    BSD General Commands Manual 						 CHPASS(1)

NAME
chpass, chfn, chsh, -- add or change user database information SYNOPSIS
chpass [-a list] [-p encpass] [-e expiretime] [-s newshell] [user] DESCRIPTION
The chpass utility allows editing of the user database information associated with user or, by default, the current user. The chfn, and chsh utilities behave identically to chpass. (There is only one program.) The information is formatted and supplied to an editor for changes. Only the information that the user is allowed to change is displayed. The options are as follows: -a The super-user is allowed to directly supply a user database entry, in the format specified by passwd(5), as an argument. This argu- ment must be a colon (``:'') separated list of all the user database fields, although they may be empty. [Note that this only changes the user database, master.passwd.] -p The super-user is allowed to directly supply an encrypted password field, in the format used by crypt(3), as an argument. [See the discussion in getpwent(3) about types of passwords; this option may not be appropriate.] -e expiretime Change the account expire time. This option is used to set the expire time from a script as if it was done in the interactive edi- tor. -s newshell Attempt to change the user's shell to newshell. Possible display items are as follows: Login: user's login name Password: user's encrypted password [do not use this to change a password; use passwd(1) instead] Uid: user's login Gid: user's login group Class: user's general classification Change: password change time Expire: account expiration time Full Name: user's real name (*) Home Directory: user's home directory Shell: user's login shell NOTE(*) - Historically, the so-call "GECOS" field in the user database entry contain the full name plus other information. Only the full name is currently supported. The login field is the user name used to access the computer account. The password field contains the encrypted form of the user's password. Do not use this to change a password; use passwd(1) instead. The uid field is the number associated with the login field. Both of these fields should be unique across the system (and often across a group of systems) as they control file access. While it is possible to have multiple entries with identical login names and/or identical user id's, it is usually a mistake to do so. Rou- tines that manipulate these files will often return only one of the multiple entries, and that one by random selection. The group field is the group that the user will be placed in at login. Since BSD supports multiple groups (see groups(1)) this field cur- rently has little special meaning. This field may be filled in with either a number or a group name (see group(5)). The class field references class descriptions in /etc/login.conf and is typically used to initialize the user's system resource limits when they login. The change field is the date by which the password must be changed. The expire field is the date on which the account expires. Both the change and expire fields should be entered in the form ``month day year'' where month is the month name (the first three characters are sufficient), day is the day of the month, and year is the year. The full name field contains the full name of the user. The user's home directory is the full UNIX path name where the user will be placed at login. The shell field is the command interpreter the user prefers. If the shell field is empty, the Bourne shell, /bin/sh, is assumed. When altering a login shell, and not the super-user, the user may not change from a non-standard shell or to a non-standard shell. Non-standard is defined as a shell not found in /etc/shells. Once the information has been verified, chpass uses pwd_mkdb(8) to update the user database. LOOKUPD AND DIRECTORY SERVICE AWARENESS
User database entries (among other things) are under the control of lookupd(8) and may be physically located in many different places, including local and remote netinfo(5) databases, directory service agents such as LDAP servers and flat file databases such as master.passwd. This version of chpass is currently limited to changing user database entries in the flat file and local netinfo databases. ENVIRONMENT
The vi(1) editor will be used unless the environment variable EDITOR is set to an alternate editor. When the editor terminates, the informa- tion is re-read and used to update the user database itself. Only the user, or the super-user, may edit the information associated with the user. See pwd_mkdb(8) for an explanation of the impact of setting the PW_SCAN_BIG_IDS environment variable. FILES
/etc/master.passwd the user database /etc/passwd a Version 7 format password file /etc/chpass.XXXXXX temporary copy of the password file /etc/shells the list of approved shells SEE ALSO
finger(1), login(1), passwd(1), getusershell(3), login.conf(5), passwd(5), pwd_mkdb(8), vipw(8) and Robert Morris and Ken Thompson, UNIX Password security. BUGS
User information should (and eventually will) be stored elsewhere. HISTORY
The chpass utility appeared in 4.3BSD-Reno. BSD
December 30, 1993 BSD
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy