Skip to content
Advertisement

Linux/Raspberry pi user restricted to one directory

I am trying to set up a user for my raspberry pi which is restricted to one file. This means that on this file, the user has all permissions (rwx) but on all other files and directories he has not any permission, not even read.

I need this because I want to lend my raspi incl. code to someone else. The one file is my code’s config file which the person should be able to change for testing purposes. But I do not want to show my code and other settings.

I tried to set up a user and a group but this means I have to change all files/directories on the raspi. I simply want to restrict the user.

Thanks for any help. muleque

Advertisement

Answer

sudo useradd -m $USERNAME This will provide you a new user with whatever name you replace $USERNAME with. This user will have access to their own home directory and you can place this file that you want them to have access to here, /home/$USERNAME.

If you want to further restrict this user’s access to the rest of the machine you can create a chroot jail which means they can access nothing apart from this directory. There are many options for how to perform this but if the user will access the raspberry pi over SSH here is a simple example.

https://www.tecmint.com/restrict-ssh-user-to-directory-using-chrooted-jail/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement