Score:0

user that exists doesn't exist when setting chroot with usermod

cn flag

This is with Ubuntu Server 20.04. Here's my terminal session:

joek@comp1:/home/user4$ sudo usermod -R /home/user4 user4
usermod: user 'user4' does not exist
joek@comp1:/home/user4$ sudo useradd user4
useradd: user 'user4' already exists
joek@comp1:/home/user4$ grep user4 /etc/passwd
user4:1010:1011::/home/user4:/bin/sh
joek@comp1:/home/user4$ grep user4 etc/passwd
user4:1010:1011::/home/user4:/bin/sh

I couldn't find an answer anywhere. How can I chroot the user into /home/user4?

Edit:

I haven't created a chroot. I only have a directory with /bin, /home, etc.

The user is used by rsync on someone else's computer to send backups to my computer. I don't want them to have access to everything on my computer.

in flag
You might need to add more details about what you are doing here. I don't think you have given us enough context to understand your problem You are asking about `chroot` but the output you pasted doesn't show you running `chroot` at all. You haven't told us how you created the chroot. BTW, what are you making a chroot for?
jkoop avatar
cn flag
I was too vague; sorry. I edited my question to answer your questions
Score:2
cn flag

The -R flag on chroot, runs everything inside a chroot environment, it says the user does not exist because it is looking for the passwd file inside /home/user4/etc/ which probably does not exist.

The command you want is probably sudo usermod -d /home/user4 user4 to change the home directory.

To enforce a sandboxed environment where the user see's /home/user4 as their own root path is not managed by the passwd file or usermod command.

Some more information here.

https://help.ubuntu.com/community/BasicChroot

jkoop avatar
cn flag
the passwd file does exist: `user4:1010:1011::/home/user4:/bin/sh`
Chris C avatar
cn flag
You posted the line from the passwd file, not the location of the file, the file is probably at /etc/passwd.
jkoop avatar
cn flag
No, this is from `/home/user4/etc/passwd`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.