How to set Access/Restrictions on users logins

I wanted to enable time limit for some users so they are able to use FTP server only during working time.

For RH based systems with Vsftpd

Open /etc/security/time.conf and add

vsftpd;*;SOME_USER;Al0800-1600

to the end.

Then open /etc/pam.d/vsftpd and add

account    required     pam_time.so

as the first line in account section so the file looks a like:

#%PAM-1.0
session    optional     pam_keyinit.so    force revoke
auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
auth       required     pam_shells.so
auth       include      password-auth
account    required     pam_time.so
account    include      password-auth
session    required     pam_loginuid.so
session    include      password-auth

Save the changes and try to login via ftp. In case you want to disable SSH, you should do the same:

Add

account    required     pam_time.so

inside /etc/pam.d/sshd and

sshd;*;SOME_USER;Al0800-1600

inside /etc/security/time.conf file.

Leave a Reply

Your email address will not be published. Required fields are marked *