How to restrict user to a particular folder in CentOS 6?
        Posted  
        
            by 
                Chris Demetriad
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by Chris Demetriad
        
        
        
        Published on 2012-03-27T13:43:58Z
        Indexed on 
            2012/03/27
            17:34 UTC
        
        
        Read the original article
        Hit count: 489
        
I will need to create users so developers can log in and clone/pull/push changes/repositories from a github like platform.
I've managed to add a user (using the root) to this CentOS machine; I now have this line in /etc/passwd:
chris:x:32008:32010::/home/chris/public_html:/bin/bash
..and this in /etc/shadow:
chris:$1$ruUeLtTu$onAY2hdu1J.UmHajEIlmR.:15385:0:99999:7:::
I am able to SSH the server, I have permission to create a folder and I guess that should be enough. But I am able to see other files and folders outside public_html.
How can I actually restrict the user to a particular directory so he can't "cd out" of his folder?
Update:
root@echo [~]# ls -ld /home/moove
drwx--x--x 21 moove moove 4096 Mar 22 16:16 /home/moove/
root@echo [~]# ls -ld /home/moove/public_html
drwxr-x--- 11 moove nobody 4096 Mar 27 11:29 /home/moove/public_html/
root@echo [~]# ls -ld /home/moove/public_html/dev
drwxr-x--- 12 moove nobody 4096 Mar 27 14:47 /home/moove/public_html/dev/
root@echo [~]# ls -ld /home/moove/public_html/dev/arsenal
drwxr-xr-x 3 arsenal moove 4096 Mar 27 14:53 /home/moove/public_html/dev/arsenal/
        © Server Fault or respective owner