Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to disable or enable a user from login with both ssh and serial port?
Do I do
passwd -l user
passwd -u user?
did you try those commands?? did they work?? another approach would be to simply change the account's shell to /usr/sbin/nologin or something like that, by editing /etc/passwd...
So you want to limit where certain users or group(s) of users and login from, rather than lock out their account.
For ssh, you can use AllowUsers or AllowGroups to explicitly determine who is allowed to login via ssh. Using AllowUser user1
will only allow user1 to log in and will deny all other users, including system users who are targets of brute force attacks.
Suppose you only want root to be able to login to tty1.
You can control that with an /etc/security/access.conf entry.
-:ALL EXCEPT root:tty1
This file is well commented. If yours isn't, then look in man 5 access.conf and man pam_access.
You can prevent a normal user from logging in on certain terminals. They will still be able to log in on other terminals. For example, you asked about a serial terminal. Maybe you only want a member of an admin group to be allowed to login to that terminal. Suppose that you only want three particular users to be able to use ssh. They might be the people who administer the server and need to do so remotely. Adding their names to the AllowUsers entry will deny ssh logins under any other account. You still want a normal user to be able to login normally.
I just reviewed the manpage for the "passwd" command. I should have used the term "lock" instead of disable. The root user can lock an account using the passwd command. That user will not be able to login. Your query seemed to me to be about limiting logins on certain terminals and on restricting who can use ssh to login. In other words, about controlling access rather than denying it completely.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.