LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   User account locking questions (https://www.linuxquestions.org/questions/linux-security-4/user-account-locking-questions-929280/)

dedec0 02-14-2012 07:53 AM

User account locking questions
 
userdel man page says:

Quote:

CAVEATS
userdel will not allow you to remove an account if there are running processes which belong to this account. In that case, you may have to kill those processes or lock the user's password or account and remove the account later.
How do I lock an user account or password? Only with usermod -L?

When I want to stop an user from logging into a system, but keep his files (e.g., to be analysed or just kept), is one of these best or bad?

- just locking the account, or
- remove his account but keeping his files, or
- backup his files and removing the user completely

What choices would have the same steps across most flavors of systems?

Noway2 02-14-2012 08:02 AM

Locking the account should prevent login. Off hand, I think you could also set the login terminal to /bin/false and accomplish the same thing. A simple option would be, as root, to change their password to something that they would have an extremely hard time guessing.

T3RM1NVT0R 02-14-2012 08:08 AM

@ Reply
 
Hi dedec0,

It is always a good practice to remove the user account when you know that this account will not be used in future. However, if you have scenario wherein there are chances of that user coming back then it is better to keep his account disabled for that time frame.

Let me put it in simple way. Disable the user account using usermod -L for a month. If that user does not comes back then delete the user account. Ofcourse you have to maintain a sheet which will keep a record when you have disabled the user account and when you should delete it.

It is always a good idea to retain the data belongs to the user you will going to delete for audit purpose. You can find out the files that were owned/created by the user using find / -user <username> command.

Procedure will look like as follows:

1. Disable the user account and keep it disabled for a month.
2. If your comes back within a month re-enable the account, reset the password and give credential to the user.
3. If user does not comes back then find out all the files owned/created by him using find command. Make a copy of it under some backup directory and delete the user account.

anomie 02-14-2012 09:34 AM

Cleaning up when a user leaves.
 
Quote:

Originally Posted by dedec0
What choices would have the same steps across most flavors of systems?

I have a procedure that I follow on both GNU/Linux and FreeBSD systems. (Note that - for FreeBSD - some commands differ from what I'll post below.) As a general rule, I do not remove old accounts. UIDs are preserved/retired when users leave, for auditing purposes.

Eliminate shell login ability

Code:

# passwd -l joe

# chsh -s /sbin/nologin joe

Cut off home directory access

Code:

# mv /home/joe /home/joe.gone

# chown root /home/joe.gone

# chmod go-rwx /home/joe.gone

Check for scheduled jobs

Code:

# crontab -u joe -l

# atq

Remove sudoer privileges

Code:

# visudo
Check for running processes

Code:

# ps aux | grep '^joe'
Find owned files

Code:

# find / -user joe > joe-files
(You'll need to make a determination about which to keep, change ownership on, remove, etc.)


All times are GMT -5. The time now is 06:37 AM.