1

I need set the folder /usr/share/nginx/site/folder as home folder and restrict this user to don't view/download other up folders...my idea is, permit the access just via sftp.

Has a website running on site folder.

I try:

1- Create a user and set /usr/share/nginx/site/folder as the first folder on login via sftp..but the user see other folders...

Any idea?

2
  • 1
    You have to configure chrooted sftp environment.
    – Kadir
    Nov 5, 2015 at 13:07
  • I tried, but i could not set correctly. this link Nov 5, 2015 at 13:45

1 Answer 1

0

Create a new user with its home directory set to the one you need him to have access to (this command must be run under sudo or in root shell):

adduser --home /restricted/directory restricted_user

This will create a user restricted_user, the directory /restricted/directory and then permissions on the directory will be set so the user can write to it. It won't have an ability to write to any other directory by default.

If you have the directory already, you can run adduser command with a --no-create-home option appended and set permissions manually (also with root privileges), like:

chown restricted_user:restricted_user /restricted/directory
chmod 755 /restricted/directory

If you need to make even world-writable directories unaccessible for this user, there are two variants.

If you want to provide an interactive shell session to the user, then consider following this manual on creating a chroot jail (in your /restricted/directory).

After that, add the following to your sshd_config:

Match user restricted_user
  ChrootDirectory /restricted/directory

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .