Error : You are required to change your password immediately (root enforced)

13,232

Solution 1

For anyone who comes across this when dealing with eg. DigitalOcean machines which are set up this way, and don't feel like manually fixing this because they automate deployments anyway and only use publickey authentication, here's an Ansible task to fix this:

# http://docs.ansible.com/ansible/lineinfile_module.html
# Get rid of DO's root password and 'you must change next time you login' stuff
- name: Setup root account properly
  lineinfile:
    backup: yes
    dest: /etc/shadow
    regexp: "^root:.*$"
    state: present
    line: "root:*:16231:0:99999:7:::"

Solution 2

In my case I wanted to install MySQL 8.0 non-interactively in the User Data specified when creating the droplet instance, and it showed the error You are required to change your password immediately (root enforced).

My solution is based on the answer of unilynx, but without needing Ansible (because the user data is run before ansible runs the tasks in the host):

sed -i 's/^root:.*$/root:*:16231:0:99999:7:::/' /etc/shadow

This way the root account is disabled for login, but I don't receive the error I mentioned above.

Share:
13,232
prashanth cm
Author by

prashanth cm

Updated on June 13, 2022

Comments

  • prashanth cm
    prashanth cm almost 2 years

    I'm trying to add a new use to a linux machine. I used this command.

    adduser "user_name" -u "UID" -G "GROUP_NAME"
    

    the entry what is see in /etc/shadow is

    "user_name":$1$IfBL9BXC$ealgUJum3HJsDRqOUY74O1:0:0:99999::::
    

    But when I try to login with the same user name,my password was accepted but immediately asked me to change password as below.

    You are required to change your password immediately (root enforced)  
    

    What should I do?

  • prashanth cm
    prashanth cm over 8 years
    thanks.. it works,, but what kind of risk it involves??
  • Marcelo Cerri
    Marcelo Cerri over 8 years
    If you change something else by mistake in this file you can lock your user.
  • BluePython
    BluePython about 8 years
    is this a default behavior of a particular linux distro? I am getting it when using ssh into a CentOs machine.