3

We have several administrators on our Debian servers and one has left our company. In leaving, he removed his own account. He was the first user on a bunch of our systems, so now any files that he created that were not in his home directory are owned by user 1000. I have several questions regarding this situation:

Question 1 Was he right to delete his account completely? In doing so, Git repositories, websites we serve, config files, shared scripts, etc. are now all owned by user 1000. I understand that a username is just an alias for a UID, but this seems like an ugly situation on a server.

Question 2 I recently ran adduser to add a new user account on the system and this user was granted ID 1000. This is clearly a problem because this non administrator was made the owner of the shared files that the former admin had created.

How does adduser determine which UID to use? I know you can specify the UID on the adduser command line. I'm just wondering why it would be set up to use the lowest UID.

Question 3 In general, what is the best practice for removing an administrator account from a server? We only allow public key ssh access to our server, so I thought it would be sufficient to remove the user's .ssh directory and remove the user from any groups s/he belongs to. But, if you could provide me with the best practice for removing a former administrator's access to a server, that would be really great.

Question 4 What should we do now, given that the administrator has removed his account? Should I make his account again and assign it UID 1000?

  • Couldn't you remove that newly created user, add a new user which will be your second user, you make it administrator and use that to alter the files with UID1000? Please note, I'm not an expert in linux. – LPChip Dec 14 '15 at 15:19
2

Question 1 Was he right to delete his account completely? In doing so, git repositories, websites we serve, config files, shared scripts, etc. are now all owned by user 1000. I understand that a username is just an alias for a UID, but this seems like an ugly situation on a server.

That depends on the content of his home directory. If it had purely personal files, then I'd do the same. If there were content regarding the administration of the server, then he should not have done it. But this is a merely personal opinion. What seems a bigger problem to me is that there are server daemons/configurations that have his UID. Not because it means something won't work, but this kind of content shouldn't have a "personal" account assigned to it. Anyway, you can change all files with UID 1000 to a different one (say 1, for root) in a simple command. See the man page for find, concretely the -uid option.

Question 2 I recently run adduser to add a new user account on the system and this user was granted ID 1000. This is clearly a problem because this non administrator was made the owner of the shared files that the former admin had created. How does adduser determine which UID to use? I know you can specify the UID on the adduser command line. I'm just wondering why it would be set up to use the lowest UID.

The system gets this from the /etc/passwd file. There are some defaults that change the behavior of the useradd command, usually in the file /etc/login.defs, though.

Question 3 In general, what is the best practice for removing an administrator account from a server? We only allow public key ssh access to our server, so I thought it would be sufficient to remove the user's .ssh directory and remove the user from any groups s/he belongs to. But, if you could provide me with the best practice for removing a former administrator's access to a server, that would be really great.

If I had to do this, I'd just lock the account initially (see man usermod, option -L), and once I've determined that it is safe to remove the account, I'd delete it with userdel -r. Having unused logins in the system is always a risk and there's no reason to keep them once you've seen that there's nothing interesting left in their home directory.

Question 4 What should we do now, given that the administrator has removed his account? Should I make his account again and assign it UID 1000?

I'd change the user ID of the user that now has the UID 1000 using the usermod command (look for the UID option), then use the find command as I answered in the first question for the root directory (/) and change ownership of all files with UID 1000 to be root, for instance. Something like this should work:

find / -uid 1000 -exec chown root:root {} +
  • In your response to Q.1, I agree that daemons shouldn't have a user id associated with them. But what about shared scripts (stored in /usr/local/sbin? Shared git repositories (stored in /srv)? What about web page files? It makes sense to me that these would be owned by a particular user even though they're in the shared part of the system. Removing the user results in these files being owned by his UID. Are you saying I should change the ownership of these files to be someone else that's an administrator? Doing so results in the loss of information of who actually created the files. – houtanb Dec 14 '15 at 15:41
  • On most used Linux distributions, most daemons use their own user. For example on ubuntu, apache2 has a user called www-data, which usually is the owner for served files. Same happens for thw git server, where the running server has the user git for that purpose. Usually it doesn't matter who created a file, but rather who can access it. For shared scripts, simply set them the execution bit for everyone, then you can safely change the owner to root, as the functionality remains the same. That's the principle that is usually applied to shared files/daemons. – nKn Dec 14 '15 at 16:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.