How to change password and set password complexity policy in Ubuntu

How to change password and set password complexity policy in Ubuntu

1. Change password

1. Modify the password of ordinary users

passwd

Enter the current password to confirm, then enter the new password to modify

insert image description here

2. Change the root user password

sudo passwd root 

insert image description here

By default, the root user is prohibited from logging in. If you need to remove the restriction, just modify the configuration

sudo vim /etc/ssh/sshd_config

Comment out the default configuration and add a new line of configuration. The default configuration allows root login, but prohibits root from logging in with a password.

PermitRootLogin prohibit-password → PermitRootLogin yes 

insert image description here

sudo service ssh restart

2. Password complexity strategy

Notice! ! ! Before setting the complexity policy, you should first change the password of the current system user to a password that complies with the complexity policy. If it does not comply, the user will be at risk of not being able to log in after setting the complexity policy. Reasonable planning is required in advance.

1. Install the cracklib module

Install the cracklib module of PAM, which provides additional password checking capabilities

sudo apt-get install libpam-cracklib

2. Related policy settings (1) Prohibit the use of old passwords

sudo vim /etc/pam.d/common-password

Find the following configuration and add remember=5 at the end, which means that the last five passwords cannot be used. The used passwords will be saved in /etc/security/opasswd

insert image description here
insert image description here

(2) Set the minimum password length

sudo vim /etc/pam.d/common-password

Find the following configuration and change the default minlen=8 to minlen=10 , indicating that the minimum password length needs to be 10

insert image description here
insert image description here

(3) Set password complexity

sudo vim /etc/pam.d/common-password

Find the following configuration and add ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 at the end. It means that the password must contain at least one uppercase letter (ucredit), one lowercase letter (lcredit), one number (dcredit) and one punctuation mark (ocredit). You can modify it as needed.

insert image description here

(4) Set password expiration date

sudo vim /etc/login.defs

Find the following configuration. The default is 9999 days, which is equivalent to no limit. The user will be prompted to change the password 7 days before the expiration date. You can modify it according to your needs.

insert image description here

PASS_MAX_DAYS 180 PASS_MIN_DAYS 0 PASS_WARN_AGE 14

Summarize

This is the end of this article about Ubuntu password modification and password complexity policy settings. For more relevant Ubuntu password modification content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to the startup error problem of AndroidStudio4.1 under Ubuntu
  • Solution to the error problem of Vscode remotely connecting to Ubuntu
  • Detailed tutorial on using VS Code and installing C/C++ plugins in Ubuntu
  • Ubuntu opens port 22
  • How to install and configure GitLab on Ubuntu 20.04
  • How to install vncserver in Ubuntu 20.04
  • Ubuntu20.04 VNC installation and configuration implementation
  • Ubuntu configuration Pytorch on Graph (PoG) environment process diagram

<<:  MySQL GROUP_CONCAT limitation solution

>>:  Detailed explanation of how to use the Vue license plate search component

Recommend

React implements infinite loop scrolling information

This article shares the specific code of react to...

Win2008 Server Security Check Steps Guide (Daily Maintenance Instructions)

The document has been written for a while, but I ...

WEB standard web page structure

Whether it is the background image or the text siz...

Why does using limit in MySQL affect performance?

First, let me explain the version of MySQL: mysql...

jQuery implements clicking left and right buttons to switch pictures

This article example shares the specific code of ...

How to implement scheduled automatic backup of MySQL under CentOS7

The happiest thing that happens in a production e...

Detailed tutorial on compiling and installing MySQL 5.7.24 on CentOS7

Table of contents Install Dependencies Install bo...

Docker5 full-featured harbor warehouse construction process

Harbor is an enterprise-level registry server for...

In-depth understanding of the vertical-align property and baseline issues in CSS

vertical-align attribute is mainly used to change...

Summary of commonly used tags in HTML (must read)

Content Detail Tags: <h1>~<h6>Title T...

CSS implements the web component function of sliding the message panel

Hello everyone, I wonder if you have the same con...

22 Vue optimization tips (project practical)

Table of contents Code Optimization Using key in ...

How to use positioning to center elements (web page layout tips)

How to center an element in the browser window He...