Solved

How to use PAM to restrict user login for certain time

Posted on 2010-08-29
12
941 Views
Last Modified: 2013-12-06
Hi guys,
I think PAM is used with NIS, by creating users on NIS server and enable client to login to their machines through users created on NIS server (just like windows active directory).

The question is can I use PAM to on local machine (without using NIS)  to restrict users login to linux system for certain time?
0
Comment
Question by:rawandnet
  • 6
  • 5
12 Comments
 
LVL 7

Expert Comment

by:mcuk_storm
ID: 33553479
There is a useful guide on this topic over at techrepublic: http://articles.techrepublic.com.com/5100-10878_11-1055269.html
0
 

Author Comment

by:rawandnet
ID: 33564886
I have followed all steps, but it has no affect, It is just like nothing been done!!
0
 
LVL 14

Expert Comment

by:cjl7
ID: 33584076
Make sure your system-auth-ac loads the correct sub-sections of pam. For example "session".

//jonas
0
 

Author Comment

by:rawandnet
ID: 33584201
how to do that?
0
 
LVL 14

Expert Comment

by:cjl7
ID: 33588248
Could you post your /etc/pam.d/system-auth-ac ?

//jonas
0
 

Author Comment

by:rawandnet
ID: 33605697
content fo /etc/pam.d/system-auth-ac is:
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 14

Expert Comment

by:cjl7
ID: 33628212
Well, you need to enable the module (pam_time) in the account section.

Be very careful, this might break things!!! Do not logout of all your shells as root when you try this!!! (and so on...)

Consider yourself warned. ;)

If you have followed the HOWTO mentioned before all you need to enforce this is to add the following to your system-auth-ac in the account section

account  required  pam_time.so

You don't need to restart pam to test this, and be sure to verify thoroughly before you logout of your shells.

//jonas
0
 

Author Comment

by:rawandnet
ID: 33660224

Under /etc/pam.d/system-auth-ac I added the highlighted text.
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so
 
account     required      pam_time.so
account     required      pam_unix.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so
 
password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nis nullok try_first_pass use_authtok
password    required      pam_deny.so
 
session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
 


Under /etc/security/time.conf for testing I denied access to all users, including root
*;*;*;!A10000-2400
But still root users and other users can login to the system, why is that?
0
 
LVL 14

Expert Comment

by:cjl7
ID: 33662273
Hmm, try to put it under the 'session' part.
0
 

Author Comment

by:rawandnet
ID: 33669428
still deoesn't work! put it under

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
account     required      pam_time.so
0
 
LVL 14

Accepted Solution

by:
cjl7 earned 500 total points
ID: 33669792
Sorry, my bad.

You have to change account     required      pam_time.so  to session     required      pam_time.so
0
 

Author Closing Comment

by:rawandnet
ID: 33700049
thank you
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order for businesses to be compliant with certain information security laws in some countries, you need to be able to prove that a user (which user it was becomes important to the business to take action against the user after an event has occurr…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now