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.
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