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 objetive is to create a new user with access vía SFTP to /var/www

Following the tutorial edited sshd_config

sudo nano /etc/ssh/sshd_config

Added this to the file

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

And restarted SSH

sudo service ssh restart

Created new group

sudo addgroup sftp

Create new user

sudo useradd -m sftpuser -g sftp

Set user password

sudo passwd sftpuser

After this I try to connect to the server using SFTP and works but when I go to /var/www 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

I need this user to work for /var/www it is his only function. The server has another users and I'm worried of breaking something if I mess arround with the permission of folders.

New contributor
Agustín Fiori is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0
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.

Your Answer

Agustín Fiori is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.