Linux/Ubuntu下限制用户在特定目录的权限

建立用户shell

若是你想将用户的读写执行权限限制在,/home/users_you_create目录下,建立用户的时候使用如下的shell便可:ssh

# adduser --home /restricted/users_you_create restricted_user spa

这样将会建立一个用户名为restricted_user 用户,如此,默认状况下将没法对其余目录使用写权限。rest

    若是你已经存在该目录,你能够采用如下的方式ci

 # adduser --home /restricted/users_you_create restricted_user  --no-create-homeget

    此时,你须要对刚刚建立的目录进行权限的设置io

chown restricted_user:restricted_user /restricted/users_you_create  //设置目录对应的用户属组
chmod 755 /restricted/users_you_create   //修改建立目录的读写权限权限

注:restricted用户没有sudo的权限,若是须要提高该权限,还须要采用visudo的方式对/etc/sudoer进行编辑,这样来达到最高权限。vi

参考:http://superuser.com/questions/149404/how-can-i-create-an-ssh-user-who-only-has-permission-to-access-specific-foldersco

相关文章
相关标签/搜索