Hello guys! Here we’ll discuss another security feature of Linux and that’s Time based Login permission for users. It means that users can login only in the time period specified. So let’s have a look upon how it’s going to be done.

Open /etc/security/time.conf file. If you remember we discussed /etc/security/limits.conf file recently which is also a useful one. If you missed that article then you can have a quick look to that . OK! Let’s come back to our main topic. Now in the opened file make an entry  like this-

  • login;*;viny;Al0800-1800

Now open /etc/pam.d/login and write-account required pam_time.so and save the file.

This shows that user viny is allowed to login from any terminal between 8AM to 6PM everyday. Now set the current time to 7PM or more and try to login as user viny. You won’t be able to login guys.

You can configure this in a variety of ways and for any service beside login. For example-

  • login;*;viny;Wk1630-2000 | Wd0800-2230

will allow access from 4:30PM to 8PM on weekdays and from 8AM to 10:30PM on weekends. For detail information view man page of this file.

Advertisements