• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to change password hashing algorithm

by admin

authconfig

The Linux user password hashing algorithm is also configurable. Use the authconfig command to determine the current algorithm being used, or to set it to something different. To determine the current algorithm:

# authconfig --test | grep hashing
 password hashing algorithm is sha512

Change the hashing algorithm

To change the algorithm, use the –passalgo option with one of the following as a parameter: descrypt, bigcrypt, md5, sha256, or sha512, followed by the –update option.

# authconfig --passalgo=md5 --update
Notes : The new algorithm in passwd/shadow files will apply until next execution of passwd command.

Forcing users to switch to new algorithm

When the hashing algorithm is changed, by default existing users need to change thier passwords, in order to use the new algorithm. You can either :
1. change all non-root users passwords or
2. force users to change the passwords on next login.

1. change all non-root users password
Here is a small for loop to change the passwords of all non-root users to be same as their usernames.

# for i in `cat /etc/shadow | awk -F: '{if ( $1 != "root" && $2 ~ /^!?[[:alnum:]./$]/ ) print $1}'`
do
passwd --stdin $i <<<$i
done

2. Force all non-root users to change their password on login
Similar to above loop, we can also force non-root users to change their passwords on next login :

# for i in `cat /etc/shadow | awk -F: '{if ( $1 != "root" && $2 ~ /^!?[[:alnum:]./$]/ ) print $1}'`
do
chage -d0 $i <<<$i
done

Filed Under: Linux

Some more articles you might also be interested in …

  1. setsid Command Examples in Linux
  2. compare: View the difference between 2 images
  3. grex Command Examples
  4. snap Command Examples in Linux
  5. entr: Run arbitrary commands when files change
  6. repo-add: command not found
  7. ac Command Examples in Linux
  8. date Command Examples in Linux
  9. mkswap: command not found
  10. pihole Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright