LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-19-2016, 12:02 PM   #1
howie2293
LQ Newbie
 
Registered: Dec 2016
Posts: 3

Rep: Reputation: Disabled
Redhat - Change all existing users password expiry


Hi

I have an issue of needing to change the password expiry for all users on our server. Bar doing it one by one. Is there a way to change the expiry for all existing users?
 
Old 12-19-2016, 12:14 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,680

Rep: Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971Reputation: 7971
Quote:
Originally Posted by howie2293 View Post
Hi
I have an issue of needing to change the password expiry for all users on our server. Bar doing it one by one. Is there a way to change the expiry for all existing users?
Your subject line says "Redhat", but you don't say what version of Red Hat you're using, nor what authentication method you're using now (LDAP? Local?). Read the "Quesiton Guidelines" link in my posting signature.

Should be very simple to dump a list of users from the passwd file, and shove it through a bash script to change the expiry. But there isn't a way to do it for ALL users at once with one command. And have you called Red Hat support?? If you're using RHEL, you're PAYING for it, right???
 
Old 12-19-2016, 02:41 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,997

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Something on this line then use script to grab the users and issue the changes maybe??

https://access.redhat.com/documentat...swd-aging.html
 
Old 12-19-2016, 03:46 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
You can use this to get users of regular user ids listed in login.defs:

Code:
MIN=$(grep '^UID_MIN' /etc/login.defs)
MAX=$(grep '^UID_MAX' /etc/login.defs)
awk -F':' -v "min=${MIN##UID_MIN}" -v "max=${MAX##UID_MAX}" '{ if ( $3 >= min && $3 <= max ) print $1}' /etc/passwd >> userlist
And you could feed that into the chage command to reset the expiry of those users to, say... 60 days from now:

Code:
while read u; do
 echo "chage -M 60 $u"
 #chage -M 60 $u
done < userlist
Test that first,. if it works to satisfaction, you can remove the 'echo' part and uncomment the command. Or change it to suit your specific need.
 
Old 12-20-2016, 04:27 AM   #5
howie2293
LQ Newbie
 
Registered: Dec 2016
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Your subject line says "Redhat", but you don't say what version of Red Hat you're using, nor what authentication method you're using now (LDAP? Local?). Read the "Quesiton Guidelines" link in my posting signature.

[/B]
Apologizes the Red Hat release version is 6.7 (Santiago)

Last edited by howie2293; 12-20-2016 at 04:28 AM.
 
Old 12-20-2016, 10:35 AM   #6
Coffee!!!
LQ Newbie
 
Registered: Dec 2016
Distribution: RHEL
Posts: 18

Rep: Reputation: Disabled
Assuming you're using local password policies, here are a few basic settings:

/etc/login.defs
PASS_MAX_DAYS 60
PASS_MIN_DAYS 1
PASS_MIN_LEN 5
PASS_WARN_AGE 7

The above will assign any new users the following definitions and you can use szboardstretcher's script to assign the policies to each of the existing users.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Password policy is not updated for existing users onkarlale Linux - Server 1 01-24-2014 04:13 PM
How to set expiring password for existing users? thiyagusham Linux - Newbie 4 11-14-2012 02:15 PM
Getting password length of already existing users. vickyk Linux - Newbie 1 11-16-2011 06:40 AM
Password ageing for existing AIX users szahri AIX 1 04-12-2005 01:44 PM
Password expiry klmn1 Linux - Networking 0 12-29-2002 10:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration