0

[Ubuntu 16.04.7, ISPConfig, Jailkit]

I needed to change the UID of a newly created (jailed) user (via ISPConfig's Add Shell User function) to disambiguate from other users on the same virtual host. So I determined the next available uid and performed usermod -u xxxx UserName.

I checked the user's home directory and instead of the username showing in the user column, the uid was showing. At first I didn't think much of this result.

When I logged in as the new user, I found that, whilst everything else was working the prompt had the username was set to I have no name!. Since I didn't need/want to change the username (and did not), I was surprised by this outcome. When I performed id for this user, I got (note the user's name is not shown next to their uid):

uid=5016 gid=5007(groupName) groups=5007(groupName)

The user is definately in the /etc/passwd file.

After searching all over the place, I have not found anything that has resolved this problem. How can I fix this?

4
  • Ownership on files is recorded as the numerical uid, not the user name. usermod does not change the uid on the user's files, so the files' owner has to be changed with chown. Commented Dec 8, 2020 at 6:32
  • There are no files other than the home directory, and it's fine.
    – gone
    Commented Dec 8, 2020 at 6:41
  • @roaima, yes, there is another passwd inside the jail that I missed. If you outline how to do that, I'll mark it as the correct answer. I manually edited the <jail>/etc/passwd file manually.
    – gone
    Commented Dec 8, 2020 at 7:45
  • The home folder was automatically updated.
    – gone
    Commented Dec 8, 2020 at 7:46

1 Answer 1

0

You mentioned that this was for a jailed user. You'll therefore need to change the uid/username mapping both inside and outside the jail.

Your usermod handled the main one outside the jail but to edit the one inside you will have to use an ordinary editor (it's unlikely you'll have usermod as a command inside the jail, so you can't chroot usermod...). The file should be {JailRoot}/etc/passwd for the appropriate value of {JailRoot}. The UID is the third colon-separated field.

As a final step just for completeness, ensure that any files owned by the old UID ({oldUID}) have been transformed to the new UID ({newUID}). Obviously, if you are sure there are no such files this step can be skipped

find / -user {oldUID} -exec chown {newUID} {} +
1
  • If this does not resolve the issue, another possible cause is version conflicts between files in the jail. This can occur if the jail was created some time in the past and additional tools were added more recently. Consider using jk_update or reinstalling the jail using jk_init or jk_cp.
    – gone
    Commented Dec 12, 2020 at 4:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .