Score:0

how to force user to change password after first login

in flag

I am trying to setup a rule that every newly created user must change his password after first login.

I know it can be done manually , i.e to force users to change password at next login.

chage -d 0 username
or 
passwd --expire username

The idea to make this change as permanent and each user that will be created must change it password at his first login.

I have to use this logic with my ansible playbook.

muru avatar
us flag
There's [an `expires` attribute for `user`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html#parameter-expires)
Asif Shabbir avatar
in flag
expire attribute works only if I have to create the users. I want to setup a rule when ever user is created with " useradd username" , and password is set, it should ask to change password at first login. I could not find any files that may contain this information @muru
muru avatar
us flag
I don't think that's the case. `expires` should update the attribute of existing users too. Why are you using `useradd` in Ansible, anyway?
Asif Shabbir avatar
in flag
I am NOT creating users via ansible. Users will be created manually. Just want to save this logic as permanent for existing and new users on multiple servers. I hope question is clear @muru
muru avatar
us flag
For `useradd` you could set `EXPIRE` in `/etc/default/useradd`
Asif Shabbir avatar
in flag
I have set EXPIRE=0 in /etc/default/useradd , but it has no Affect @muru. any more suggestions that I can try out.
Artur Meinild avatar
vn flag
Don't you think EXPIRE=1 if it has to work?
Asif Shabbir avatar
in flag
@ArturMeinild EXPIRE=1 also does not work.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.