LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2014, 04:06 AM   #1
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Rep: Reputation: Disabled
Force change password for users in linux, without terminating the shell session


Hello,

I am using CentOS 6.5 64 bit OS. I used chage command to force users to change their password on next login, for ex -

Code:
chage -d 0 admin
This forced the user to change the password, but terminated the session & the user was required to re-login with the new password.

Is there any way, any other command to avoid the session termination at the end of a successful password change?

Another thing I noted was that this command did not work for root user. The root user was not forced to change password. Anything I am missing here?

Thanks
Bhushan Pathak
 
Old 07-10-2014, 05:23 AM   #2
looop
Member
 
Registered: Oct 2011
Location: Denmark
Distribution: Fedora, Ubunut, macOS Mojave, RedHat, OpenBSD
Posts: 78

Rep: Reputation: Disabled
To my knowledge you can't force GOD (root) to do anything, including changing the password.
 
1 members found this post helpful.
Old 07-10-2014, 06:12 AM   #3
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Original Poster
Rep: Reputation: Disabled
ok, what about the session termination on successful password change?
 
Old 07-10-2014, 06:16 AM   #4
looop
Member
 
Registered: Oct 2011
Location: Denmark
Distribution: Fedora, Ubunut, macOS Mojave, RedHat, OpenBSD
Posts: 78

Rep: Reputation: Disabled
It is a million years since I did IDM and User mangement. So my memory is a little rusty at this subject, so instead of getting your hopes up.
I hope another person will give you an answer to that question
 
Old 07-10-2014, 06:18 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I do not really understand: what do you mean by session termination? Kicking of the root user means reboot. If you want to change the password of root just do that.
 
Old 07-10-2014, 06:26 AM   #6
looop
Member
 
Registered: Oct 2011
Location: Denmark
Distribution: Fedora, Ubunut, macOS Mojave, RedHat, OpenBSD
Posts: 78

Rep: Reputation: Disabled
@pan64 - He/she wants to be able to change the password of a normal user, without terminating the users sessions. Then he asked if it was possible to force the root to change password.
Two different questions
 
Old 07-10-2014, 06:37 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
see man passwd:
Code:
      -e, --expire
           Immediately expire an account's password. This in effect can force a user to change his/her password at the user's next
           login.
only root can use it. but actually there is no meaning to force myself (root as root) to change password
 
1 members found this post helpful.
Old 07-11-2014, 02:16 AM   #8
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Original Poster
Rep: Reputation: Disabled
Anyone about the session termination on successful password change - how to avoid that?

Thanks
Bhushan Pathak
 
Old 07-11-2014, 02:49 AM   #9
looop
Member
 
Registered: Oct 2011
Location: Denmark
Distribution: Fedora, Ubunut, macOS Mojave, RedHat, OpenBSD
Posts: 78

Rep: Reputation: Disabled
@BhushanPathak as “pan64 writes see the man page, so what you do as root is:

Code:
passwd -e #username#
So the next time he/she tries to logon to the system they have to change the password, this does not kill the current session
 
Old 07-11-2014, 03:52 AM   #10
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Original Poster
Rep: Reputation: Disabled
I tried that out. I executed the following as root -

Code:
# passwd -e admin
Expiring password for user admin.
passwd: Success
I then opened a new SSH session & logged in as admin user, but I was not forced to change my password.
 
Old 07-11-2014, 03:55 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
how did you try that? With passwordless login?
 
Old 07-11-2014, 03:59 AM   #12
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Original Poster
Rep: Reputation: Disabled
Nope, I provided username & old password for admin user, but was not prompted for changing the password, like in the case when chage command is used.

Last edited by BhushanPathak; 07-11-2014 at 04:00 AM. Reason: updated the reply with details
 
Old 07-11-2014, 04:01 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
what is the user id of admin?
what is in /etc/nsswitch.conf?
 
1 members found this post helpful.
Old 07-11-2014, 04:10 AM   #14
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 85

Original Poster
Rep: Reputation: Disabled
Following are the details -
Code:
# id admin
uid=783(admin) gid=783(admin) groups=783(admin)


# cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#       nisplus                 Use NIS+ (NIS version 3)
#       nis                     Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       db                      Use the local database (.db) files
#       compat                  Use NIS on compat mode
#       hesiod                  Use Hesiod for user lookups
#       [NOTFOUND=return]       Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files
shadow:     files
group:      files

#hosts:     db files nisplus nis dns
hosts:      files dns

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus
aliases:    files nisplus
 
Old 02-20-2018, 04:30 AM   #15
jguillem
LQ Newbie
 
Registered: Feb 2018
Posts: 1

Rep: Reputation: Disabled
I have understood you

Same here.
In my case I'm using LDAP authentification.
When the parameter shadowLastChange is zero or less, the user is forced to change the password during the first autentication.
The problem is: one time the authentication is made and the user has changed his passwd, the session closes with the error "password change failed: Invalid credentials".
However, the password is changed and in the next login the new passwd works correctly.

ssh lguillem@127.0.0.1
lguillem@127.0.0.1's password:
You are required to change your password immediately (root enforced)
need a new password
Last login: Fri Feb 16 13:23:15 2018 from gateway
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user lguillem.
(current) LDAP Password:
New password:
Retype new password:
password change failed: Invalid credentials
passwd: all authentication tokens updated successfully.
Connection to 127.0.0.1 closed.
 
  


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
Linux drops session after asking me to change my password JCW1969 Linux - Newbie 7 08-28-2013 10:47 PM
How to force user to change password after expiration in Linux? ssy68 Linux - Newbie 4 06-30-2011 02:54 PM
[SOLVED] REDHAT missing functionality - force user to change password on login machielr Linux - Security 5 03-17-2011 02:36 PM
How to force a user to change their NIS password at logon? synthol6 AIX 1 08-17-2010 08:47 PM
RH 5.2 - First login: Force root password change le_forban Linux - Enterprise 2 01-20-2009 07:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:24 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