Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 746  / 1 Year ago, tue, january 10, 2023, 12:45:07

Based on Ubuntu 18.04,


I want to allow users to access only from 9 a.m. to 5 p.m.(working time) on the SSH server. (used OpenSSH-server package)


I've looked up all the materials I think will help you from user management to PAM settings on Google, but I don't think there's any information to restrict access by SSH time zone.


(But, I have not to use firewall-related services like ufw.)


If you can help me, please let me know. Thank you.


(Please understand that my English can be unnatural because I am not good at English.)


More From » 18.04

 Answers
1

Use a cron job to stop and start the ssh server at specific times. For example create a file /etc/cron.d/start-stop-ssh with the following contents:


0 9 * * * root /usr/sbin/service ssh start
0 17 * * * root /usr/sbin/service ssh stop

This will start the ssh service everyday at 9:00 and stop it everyday at 17:00.


Please note that when the service is stopped nobody (even admin) will be able to login via ssh.


[#1151] Tuesday, January 10, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ngthmated

Total Points: 12
Total Questions: 115
Total Answers: 113

Location: Saint Vincent and the Grenadines
Member since Wed, Apr 21, 2021
3 Years ago
ngthmated questions
;