0

OK, I'm a Linux newbie... I followed this tutorial https://linuxconfig.org/how-to-setup-sftp-server-on-ubuntu-18-04-bionic-beaver-with-vsftpd

My objective is to create a new user with access vía SFTP to /var/www

Following the tutorial, I edited sshd_config

sudo nano /etc/ssh/sshd_config

and added this to the file:

Match group sftp
ChrootDirectory /home
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

and restarted SSH.

sudo service ssh restart

I created a new group

sudo addgroup sftp

and a new user.

sudo useradd -m sftpuser -g sftp

I set the user password.

sudo passwd sftpuser

After this, when I try to connect to the server using SFTP, it works but when I go to /var/www, I get this error in FileZilla:

Comando:    cd "/var/www"
Error:  Directory /var/www: no such file or directory
Error:  Error al recuperar el listado del directorio (error on retrieving directory listing)

I need this user to be able to access /var/www as this is his only function. The server has other users and I'm worried about breaking something if I mess arround with the permission of folders.

1 Answer 1

1
Match group sftp
ChrootDirectory /home

Your configuration is restricting sftp users to the /home directory and its subdirectory. In fact, the /home directory will appear as the root directory to these users. /var/www is outside of /home, so it's not accessible.

You could remove the "ChrootDirectory" directive from sshd_config. Users would have access to the entire filesystem, including /var/www (subject to file permissions).

Alternately, you could use a bind mount to make /var/www accessible inside the /home directory. Bind mounts are commonly used in SFTP chroot environments.

You must log in to answer this question.

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