1

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.

jkoop
  • 11
  • 3
  • 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? – Zoredache Sep 06 '21 at 00:33
  • I was too vague; sorry. I edited my question to answer your questions – jkoop Sep 06 '21 at 19:35

1 Answers1

2

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

Chris C
  • 61
  • 1