LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-01-2007, 10:02 AM   #1
alagesh146
LQ Newbie
 
Registered: Oct 2006
Posts: 1

Rep: Reputation: 0
how to restrict a user logging with particular time


hi
i need to know how to set user login times that is for eg
a user USER1 has login access only between 10 am to 4 pm,
which configuration file i need to modify, send me suggesstions
at alagesh146@gmail.com
 
Old 08-01-2007, 12:03 PM   #2
timvc
LQ Newbie
 
Registered: Nov 2006
Posts: 5

Rep: Reputation: 0
In order to lock and unlock a user's periodically, make two 'cron'-directories:
# mkdir /etc/cron.lockuser
# echo "/usr/sbin/usermod -L USER1" > /etc/cron.lockuser/lockuser1
# chmod a+x /etc/cron.lockuser/lockuser1
# mkdir /etc/cron.unlockuser
# echo "/usr/sbin/usermod -U USER1" > /etc/cron.unlockuser/unlockuser1
# chmod a+x /etc/cron.unlockuser/unlockuser1

end then edit the file /etc/crontab with two extra lines:

00 10 * * * root run-parts /etc/cron.unlockuser
00 16 * * * root run-parts /etc/cron.lockuser

This will enable the password for USER1 from 10.00h until 16.00h. If the user uses another type of authentication to log in, you may want to change the lockuser1 and unlockuser1 files in another way:

# echo "/usr/bin/chsh -s /sbin/nologin USER1" > /etc/cron.lockuser/lockuser1
# chmod a+x /etc/cron.lockuser/lockuser1
# echo "/usr/bin/chsh -s /bin/bash USER1" > /etc/cron.unlockuser/unlockuser1
# chmod a+x /etc/cron.unlockuser/unlockuser1

this worked for me
regards
 
Old 08-01-2007, 02:00 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
How about PAM? As in /etc/security/time.conf?
And no we don't do email, that's just too lazy of you.
 
Old 08-01-2007, 07:41 PM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
I know some sysadmins that just change the loginshell to "nologon" during times said user is not supposed to be active, of course taking account of the original shell type so they can be restored correctly.
 
  


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
samba PDC - how to restrict users with time lakshminarayan Linux - Server 0 04-18-2007 07:14 AM
restrict masqueraded users to access an IP, only one at a time Menestrel Linux - Networking 1 11-22-2005 12:46 PM
how to restrict the user simi_virgo Linux - Newbie 2 02-25-2005 06:31 AM
Restrict users logging in by SSH tolindsey Linux - Security 4 08-12-2004 04:17 PM
Restrict Logon Time javalino Linux - Security 2 04-27-2004 05:56 PM

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

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