Discussion Locked

Change Linux passwords for all users

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to change the password for ever user on my Linux system. What is the easiest way to do this. (I am NOT Linux/Unix script savy)

5 replies

by rkeckler2000

The following is a perl program.
Make sure perl is in the /usr/bin directory.
chmod this file to 744 and chown to root
run the program as root
It will change all passwds (including root) to
password except those that have and * or !! for the passwd. These lines are Locked accounts or No passwd accounts.

WARNING WARNING
I am not responsible for this script
MAKE A COPY OF THE /ETC/SHADOW FILE
BEFORE RUNNING THE SCRIPT
DOUBLE CHECK!!!!!!!!
WARNING WARNING

#!/usr/bin/perl
use strict;

my $SHADOW = '/etc/shadow';
my $PASSWD = 'password';
my @lines;
my $salt = chr(int(rand(26)) + 65) . chr(int(rand(26)) + 65);
my $encrypt = crypt $PASSWD, $salt;
open SHADOW, "< $SHADOW" or
die "$0: unable to open $SHADOW: $!
\n";

@lines = ;

close SHADOW;
foreach (@lines) {
not /!!/ and not /\*/ and do { s/:\w*:/:$encrypt:/;
};
}
open SHADOW, "> $SHADOW" or
die "$0: unable to open $SHADOW: $!
\n";

foreach (@lines) {
print SHADOW;
}

by hugevlad

Look throu /etc/defaults (depends of your Linux distribution) and change password aging policies. At the next logon each user will be prompted to change his password.

With best regards,
Vlad.
mailto:hugevlad@yahoo.com

This discussion is closed to new replies.