Best way to lock out a group once per week [duplicate]

A SSH server I admin is to be allowed login from a group of users all days of week except sunday.

How would be your elegant solution to this? Thanks any input on comments or creative +and+ secure answers.

It should also kick out logged users. And take care of any means of login, such as passwords or ssh-keys.

(Edited as suggested)


Solution 1:

Combining pam_time from the question I mentioned with a cron job that runs periodically on sundays should accomplish what you want.

The cron job enumerates logged in users with a terminal (with who) and with an uid >= 1000 and calls pkill -HUP -u <user>. Might be a little more complicated with X sessions.

This approach is problematic though - we have no idea about the environment in which you are planning to use this. Users might (understandably) not take kindly to having their work terminated without a chance to save, or might plan to have a job running for a long time that needs a terminal.