LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-17-2010, 04:45 AM   #1
sulekha
Member
 
Registered: Dec 2004
Location: India
Distribution: ubuntu 10.04 , centos 5.5 , Debian lenny, Freenas
Posts: 324

Rep: Reputation: 36
Question prevent users from changing their password ?


Hi all,

I use the following method for preventing the users from changing their passwords , is there any other method other than this ?


ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root 37140 2010-01-26 12:09 /usr/bin/passwd

so we need to remove the suid for that command as follows :- chmod u-s /usr/bin/passwd

now normal users won't be able to change their own passwords - and only the root user will be able to do it for them.
 
Old 07-17-2010, 06:34 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
On systems using PAM you could add a "pam_listfile.so" line to /etc/pam.d/passwd and configure the list it only allow or deny certain users to change their password. An upgrade of the package containing /usr/bin/passwd might reset the setuid bit. That change might escape your attention unless you monitor or regularly audit file permissions.
 
Old 07-17-2010, 08:34 AM   #3
mlnutt
Member
 
Registered: May 2006
Posts: 34

Rep: Reputation: 15
You could also move "passwd" to /root/bin.
 
Old 07-17-2010, 05:02 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Quote:
Originally Posted by mlnutt View Post
You could also move "passwd" to /root/bin.
Nice idea but that's not a method in any book. Doing that will break usage for legitimate processes that doesn't have /root/bin in it's $PATH. Besides an update will place the binary back where it belongs.
 
Old 07-17-2010, 05:16 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,826

Rep: Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006Reputation: 4006
Might I ask why ?.
Every site I've been to enforce password changing - usually with quite particular rules and frequency.
 
1 members found this post helpful.
Old 07-21-2010, 03:20 AM   #6
wizman56
LQ Newbie
 
Registered: Jul 2010
Location: Kuala Lumpur
Distribution: Redhat
Posts: 3

Rep: Reputation: 0
Prevent users from changing passwd?

Try setting the immutable bit on the /etc/passwd, /etc/shadow, /etc/gshadow files with the chattr command:
chattr +i /etc/shadow

To remove the immutable bit, use chattr -i
 
Old 07-23-2010, 08:32 AM   #7
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
Just do chmod go-rx /usr/bin/passwd. That way users can't run the passwd program at all.
If you want some users to change their passwords, but not others, put those users in a group, make that the group associated with passwd, and set group permissions so group members can run it.

Last edited by cantab; 07-23-2010 at 08:35 AM.
 
Old 07-24-2010, 06:39 AM   #8
wizman56
LQ Newbie
 
Registered: Jul 2010
Location: Kuala Lumpur
Distribution: Redhat
Posts: 3

Rep: Reputation: 0
Using chattr

Perhaps you guys missed the subtlety of using chattr...

Once you have used chattr, the passwd command is still available...and it even looks, to the user, as if their password is changed...but the passwd program complains silently when they use passwd. No feedback results. they simply cant change their passwd, even the root user cannot, until chattr -i is issued.

Hope this helps you guys...
 
Old 07-24-2010, 07:27 AM   #9
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by wizman56 View Post
and it even looks, to the user, as if their password is changed...No feedback results
I'd say that's a really bad idea. The last thing you want is someone thinking their password has been changed when it hasn't. You'll then have to field user complaints of "I changed my password but it didn't work" and so on. As well as the risk of a user changing their password because their old one had become known to others, and not realising the change had failed and then getting their account broken into.
 
Old 07-24-2010, 09:38 PM   #10
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
I think you guys can also use ACL in this case

As root,
Code:
chmod 000 /usr/bin/passwd
setfacl -m u:777:root /usr/bin/passwd

or rather this would be best in my opinion

Code:
mv /usr/bin/passwd /sbin
Generally, normal user dont have /sbin in $PATH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Problem changing password for local users leblinux Linux - General 1 05-06-2010 02:35 PM
Is there a way to prevent users from changing or unset their HISTFILE variable? abefroman Linux - Security 7 09-13-2009 11:41 AM
Changing password for various users with same UID kapil.kshirsagar Linux - Software 3 07-04-2008 04:36 AM
how do i prevent windows users from changing the share permission? m2azer Linux - Networking 2 01-15-2007 10:22 PM
prevent users form usins MySQL without password Punker51 Linux - Software 0 12-01-2003 09:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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