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

Blog    

Recommend

Zen Coding Easy and fast HTML writing

Zen Coding It is a text editor plugin. In a text ...

Introduction to the usage of common XHTML tags

There are many tags in XHTML, but only a few are ...

Native JS realizes the special effect of spreading love by mouse sliding

This article shares with you a js special effect ...

Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

Now 2016 server supports multi-site https service...

Summary of relevant knowledge points of ajax in jQuery

Preface Students who learn JavaScript know that A...

MySQL character types are case sensitive

By default, MySQL character types are not case-se...

MySQL 8.0.25 installation and configuration method graphic tutorial

The latest download and installation tutorial of ...

Website redesign is a difficult task for every family

<br />Every family has its own problems, and...

Detailed explanation of sshd service and service management commands under Linux

sshd SSH is the abbreviation of Secure Shell, whi...

Three implementation methods of Mysql copy table and grant analysis

How to quickly copy a table First, create a table...

Zabbix monitoring solution - the latest official version 4.4 [recommended]

Zabbix 2019/10/12 Chenxin refer to https://www.za...

Is it easy to encapsulate a pop-up component using Vue3?

Table of contents Summary put first: 🌲🌲 Preface: ...

How to install FastDFS in Docker

Pull the image docker pull season/fastdfs:1.2 Sta...

Implementation of TypeScript in React project

Table of contents 1. Introduction 2. Usage Statel...