General discussion

  • Creator
    Topic
  • #2072834

    Change Linux passwords for all users

    Locked

    by john murray ·

    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)

All Comments

  • Author
    Replies
    • #3782530

      Change Linux passwords for all users

      by rkeckler2000 ·

      In reply to Change Linux passwords for all users

      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;
      }

    • #3783256

      Change Linux passwords for all users

      by hugevlad ·

      In reply to Change Linux passwords for all users

      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

    • #3745631

      Change Linux passwords for all users

      by john murray ·

      In reply to Change Linux passwords for all users

      This question was closed by the author

Viewing 2 reply threads