View Single Post

  #1 (permalink)  
Old 12-19-2006, 08:18 AM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,060
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default Linux force user to set a password the first time they login

A simple question - How do I force user set a password the first time they log in Linux server?

And here is the answer

Step # 1: Create the user called foo:
Code:
useradd foo
Step # 2: Set the password for user foo:
Code:
passwd foo
Step # 3: Now Lock the user account :
Code:
usermod -L foo
Step # 4: Next force expiration:
Code:
chage -d 0 foo
Step # 5: Finally Unlock the user account:
Code:
usermod -U foo
You can write a script for above procedure. Skip first 2 steps if user exists in system.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote