Yuri Slobodyanyuk Blog on Information Security 2024年09月12日
Time-based access limiting on Checkpoint or any Linux for any network service
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

介绍在Linux中通过pam模块实现基于时间的访问控制,适用于多种网络服务,包括设置步骤及示例。

🎯通过pam模块实现基于时间的访问控制,几乎所有软件都支持与pam模块配合工作,使其具有通用性。如在/etc/pam.d中为感兴趣的软件启用pam_time.so模块。

📋在/etc/security/time.conf文件中配置服务接受连接的时间范围。以限制ftp_user在工作日工作时间连接vsftpd为例,进行了详细的配置说明。

🔄对于某些服务,可能需要重启以强制其使用pam_time.so模块。如首次配置vsftpd时需重启。对于Checkpoint,sshdaemon是此类限制的可能候选,同样进行了相应配置。

Time-based access-lists in Cisco world are available since ... last century for sure. But is it possible that Linux doesn't have anything like that ? No way - of course it can do and do it better. Here is how .Access control based on time of the day is available via pam module, and as almost all software today supports working with pam modules, it means it is available universally.Steps to do for any networking service:

E.g. Let's restrict user ftp_user so that it is able to connect to vsftpd daemon only during working hours of the weekdays.
- Add to file /etc/pam.d/vsftpd the following line
account required /lib/security/pam_time.so
- Set time limits in /etc/security/time.conf with this line
vsftpd;*;ftp_user;Wk0800-1700- Restart vsftpd to force it using pam_time.so module (need to do it just first time)
#service vsftpd restart

And now during the off-limit hours the ftp_user will not be able to connect by FTP, that is it .

For Checkpoint all the above holds true, but as you don't have much servers there , the most probable candidate for such restrictions is ssh daemon. For example firewall that the client has access by ssh to it as well - while mail alerts for such access (see Mail alert on ssh access in Checkpoint) will warn me about such access, it does me no good if someone on client side accesses the firewall at 02:00 am at night and I get alert . Example for limiting ssh access to the firewall to working hours only.
/etc/security/time.conf :
sshd;*;client_user;Wk0900-1900
/etc/pam.d/sshd :
account required /lib/security/pam_time.so

Related:
- Two tips to secure SSH access from specific IPs to specific users in Checkpoint or any Linux

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Linux 访问控制 pam模块 时间范围
相关文章