Sometimes we need to allow user to access SSH in a specific time interval.

For Example : Allow Mike to access SSH service between 1:00 AM to 5:00 AM.

We can achieve this using pam_time module.The pam_time module is an account module type. No arguments are passed directly to the module, but instead all configuration takes place within /etc/security/time.conf.

The time.conf operates based on rules, and each rule uses the following syntax:


Steps to be followed,

  • SSH to the server and vi /etc/pam.d/sshd

cat /etc/pam.d/sshd
auth include system-auth
account required
account required
account include system-auth
password include system-auth
session optional force revoke
session include system-auth

auth required

The one in BOLD must be added.

  • vi /etc/pam.d/system-auth

add “account     required” 

  • vi /etc/security/time.conf


  • Restart sshd service

**Available abbreviates for the days of the week

Mo : Monday
Tu : Tuesday
We : Wednesday
Th : Thursday
Fr : Friday
Sa : Saturday
Su : Sunday
Wd : Sa/Su
wk : Mo/Tu/We/Th/Fr
Al : All Days