Quantcast
Viewing latest article 2
Browse Latest Browse All 12

Answer by artfulrobot for How to prevent a user from login in, but allow "su - user" in Linux?

Assuming you only want to su user from root's account, and disable all other access:

Use this (run as root):

usermod -e 1 -L user

This disables password login (as many other answers have advised), but it also expires the account. You can't login to an expired account, e.g. with SSH keys. You can still su user, although it will display a notice that the account has expired.


Viewing latest article 2
Browse Latest Browse All 12

Trending Articles