LinuxQuestions.org
Review your favorite Linux distribution.
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 03-05-2009, 02:19 PM   #1
Mistoffeles
Member
 
Registered: Dec 2007
Location: TGWN
Distribution: Fedora, RHEL, CentOS, Evil Entity
Posts: 36

Rep: Reputation: 15
I hate PAM


ok, I don't like PAM, it's complicated and makes no sense to me at all, but I am stuck with it on my new RHEL 5.3 x86_64 server (tried to remove it once and the whole server blew up, figuratively speaking).

What I want to do is block root from logging in via ssh, but for some reason I cannot get su to work in concert with PAM. Even at the console (mouse, keyboard and monitor connected to the physical box) I am unable to su to root from any user on the system. There are only three users other than root and they are all in the wheel group.

When I try to su to root, the message I get is:

su: incorrect password

which I know is horse puckey because I can log into root using the same password from the console, but I can't su to root from my login whether I am at the console or using PuTTY.

I have tried it with various lines in /etc/pam.d/su, such as:

auth required pam_wheel.so use_uid

auth required pam_wheel.so group=wheel (seems redundant)

auth required /lib/security/pam_wheel.so use_uid

auth required /lib64/security/pam_wheel.so use_uid (x86_64 system)


also tried the last two with the group=wheel bit too.


If I had enough hair to get a grip on, it would all be ripped out by now.
 
Old 03-05-2009, 02:40 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if your goal is solely to to block root ssh logins then leave PAM alone, just edit /etc/ssh/sshd_config and set PermitRootLogins to no. OR edit /etc/security/access.conf and restrict root from logging in from any remote program.
 
Old 03-05-2009, 04:14 PM   #3
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,462
Blog Entries: 7

Rep: Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561Reputation: 2561
Try Slackware. It's PAM free since... uh... forever.
 
Old 03-05-2009, 04:34 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
That's really not helpful is it?
 
Old 03-05-2009, 04:47 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Mistoffeles
What I want to do is block root from logging in via ssh, but for some reason I cannot get su to work in concert with PAM. Even at the console (mouse, keyboard and monitor connected to the physical box) I am unable to su to root from any user on the system. There are only three users other than root and they are all in the wheel group.
Can you be a little more clear on what you're trying to accomplish? Are you trying to prevent direct root logins over ssh? Or are you trying to prevent users from logging in over ssh and then su'ing to root?

If the former, you've already been advised on the correct sshd_config option. That's a common and effective approach.

If the latter, there's a simple PAM directive you can put into place to allow only users in the wheel group to su.
 
Old 03-05-2009, 05:01 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...actually there's another option using PAM involving a simple pam_listfile entry. I agree though the generic solution of modifying sshd_config should be the first thing to do.

Last edited by unSpawn; 03-05-2009 at 05:02 PM.
 
Old 03-06-2009, 03:07 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Because the SSH option is so specific I would tend to do that for root, but with other users accounts, say you need to be a member of a certain group to log in, whilst this can be done within sshd_config I would recommend pushing it out to access.conf to make it generic.
 
Old 03-06-2009, 03:13 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If only one or two users log into ssh legitimately, I would add these users to an "AllowUsers" line in /etc/ssh/sshd_config. This will also disallow all other login attempts. This is easier then adding all system accounts to "DenyUsers". After I install a new distro, running ssh-keygen, configuring PublicKey ssh authentication and adding my username to AllowUsers is the first thing I do.
 
Old 03-09-2009, 12:24 PM   #9
Mistoffeles
Member
 
Registered: Dec 2007
Location: TGWN
Distribution: Fedora, RHEL, CentOS, Evil Entity
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
If only one or two users log into ssh legitimately, I would add these users to an "AllowUsers" line in /etc/ssh/sshd_config. This will also disallow all other login attempts. This is easier then adding all system accounts to "DenyUsers". After I install a new distro, running ssh-keygen, configuring PublicKey ssh authentication and adding my username to AllowUsers is the first thing I do.
Thanks, I know how to disallow root via sshd_config but I wanted to keep anyone not in wheel from su to root. This will do, until I can figure out the problem between su and pam.
 
Old 03-09-2009, 04:20 PM   #10
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Mistoffeles
.. but I wanted to keep anyone not in wheel from su to root. This will do, until I can figure out the problem between su and pam.
The following unified diff shows the change you need to make.
Code:
# rcsdiff -u -r1.1 /etc/pam.d/su
===================================================================
RCS file: /etc/pam.d/RCS/su,v
retrieving revision 1.1
diff -u -r1.1 /etc/pam.d/su
--- /etc/pam.d/su       2009/03/09 21:17:34     1.1
+++ /etc/pam.d/su       2009/03/09 21:18:00
@@ -3,7 +3,7 @@
 # Uncomment the following line to implicitly trust users in the "wheel" group.
 #auth          sufficient      pam_wheel.so trust use_uid
 # Uncomment the following line to require a user to be in the "wheel" group.
-#auth          required        pam_wheel.so use_uid
+auth           required        pam_wheel.so use_uid
 auth           include         system-auth
 account                sufficient      pam_succeed_if.so uid = 0 use_uid quiet
 account                include         system-auth
 
Old 04-01-2009, 04:04 PM   #11
Mistoffeles
Member
 
Registered: Dec 2007
Location: TGWN
Distribution: Fedora, RHEL, CentOS, Evil Entity
Posts: 36

Original Poster
Rep: Reputation: 15
This would be fine if

a) I knew enough about diff's display to be certain that I understand what you meant, which appears to be "uncomment the line containing 'pam_wheel.so use_uid'"

b) I had not already tried uncommenting the line that you appear to be telling me to uncomment, in the most indirect way possible, to no avail.
 
Old 04-01-2009, 04:44 PM   #12
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Mistoffeles
I knew enough about diff's display to be certain that I understand what you meant, which appears to be "uncomment the line containing 'pam_wheel.so use_uid'"
What I posted is a unified diff. You'll see them commonly used to demonstrate code changes, for example. See the diff(1) manpages for more info.

In any event your assumption is correct. All you need to do is precisely what the file comment says: uncomment that line.

Quote:
Originally Posted by Mistoffeles
I had not already tried uncommenting the line that you appear to be telling me to uncomment, in the most indirect way possible, to no avail.
Then you made the change incorrectly, tested it incorrectly, or borked something else. I didn't post that to brainstorm with you; it works and I use it myself.

---

P.S. You will find that people are more inclined to help you when you're not rude and unpleasant about it. Good life lesson for you -- it applies to more than forums.

Good luck.
 
Old 04-01-2009, 05:10 PM   #13
Mistoffeles
Member
 
Registered: Dec 2007
Location: TGWN
Distribution: Fedora, RHEL, CentOS, Evil Entity
Posts: 36

Original Poster
Rep: Reputation: 15
And do you always respond to a question by telling someone to try something that they have already tried, as stated clearly in the original question?

It is this sort of techno-snobbery, and the subsequent accusations of incompetency and rudeness that invariably follow, that continues to drive people away from Linux.

The fact is, uncommenting that line did not have any effect, and I am looking for a reason why, as I have documented and reversed any other changes I have made to the server to isolate the problem. In this case, "it doesn't work", and your offensive comments don't contribute towards a solution.

Last edited by Mistoffeles; 04-01-2009 at 05:29 PM.
 
Old 04-01-2009, 06:01 PM   #14
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Mistoffeles
And do you always respond to a question by telling someone to try something that they have already tried, as stated clearly in the original question?
I'm telling you that you "tried" it incorrectly.

Quote:
Originally Posted by Mistoffeles
It is this sort of techno-snobbery, and the subsequent accusations of incompetency and rudeness that invariably follow, that continues to drive people away from Linux.
Agreed, you are rude. The less attitudes we have like yours, the better. In spite of casting off a few jerks, the Linux community continues to grow.

Quote:
Originally Posted by Mistoffeles
... your offensive comments don't contribute towards a solution.
Hardy har. Try re-reading this thread as an objective third party and see who is making "offensive comments". Get a grip.
 
Old 04-01-2009, 06:22 PM   #15
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Many changes can be made by editing files in /etc/security/. PAM reads these files for controlling things like secure tty's, when users can login, quotas, etc. Look in /etc/security first. Each of these files have their own manpages as well.

The reason for the wheel group is so that you can allow only wheel group members to use sudo & not have to give them the root password. The sudoers file is what controls who can use sudo, not PAM. Use the "visudo" to edit it so that errors will be detected. One gotcha is that you may need to log out before changes in sudo can take effect. Group membership changes may require this in a more general sense.

To use su, a person needs to know the root password. One protection used is to use shadow passwords. Only root can read the /etc/shadow file. Another protection is using salt. This deters the use of rainbow tables in looking up passwords given the hash. The main control over su is using a strong password and controlling access to who knows the password. The main purpose of sudo is to keep the root password secret from even other administrators, backup operators, etc.
 
  


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
Help with PAM and PAM modules bourne Linux - Security 6 11-02-2008 11:48 PM
PAM module:passwd:- how many character validate by pam library amit_pansuria Linux - General 3 10-21-2008 01:19 AM
Hate it....... sgrayban Conectiva 9 04-30-2005 05:24 PM
vsftpd + pam + virtual users - Pam cannot load database file. mdkelly069 Linux - Networking 3 09-22-2004 11:07 PM

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

All times are GMT -5. The time now is 01:29 AM.

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