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

相關文章
相關標籤/搜索