In the cases when you want to limit the access to a Linux operating system in a time range, you would like to use pam_time.so. pam_time was written by Andrew G. Morgan.
Take a look at /etc/security/time.conf
To limit for example ssh access from 23:00 PM and 08:00 AM.
sshd;*;*;!Al2300-0800
The format of the file is:
Service;ttys;users;time
the !Al means, anything except "All the days".
If you would like to permit people from 4 to 8 PM all the days, except root:
login;*;!root;!Al1600-2000
Further reading:man time.conf
Take a look at /etc/security/time.conf
To limit for example ssh access from 23:00 PM and 08:00 AM.
sshd;*;*;!Al2300-0800
The format of the file is:
Service;ttys;users;time
the !Al means, anything except "All the days".
If you would like to permit people from 4 to 8 PM all the days, except root:
login;*;!root;!Al1600-2000
Further reading:man time.conf