4

I have some users on my Ubuntu server with vsftpd installed.
The server is used as web server and has a shared sftp directory that is accessed by public clients (by giving them the user and password).

Due to that architecture, my goal was to restrict the public client user to access his home directory only and restrict the access to the other directorys. I did it using ChrootDirectory as follows:

  • create the public user: public_sftp with the home dir: /home/public_sftp/
  • /home/public_sftp is owned by root
  • Inside /home/public_sftp, there are two dirs owned by public_sftp:www-data
  • create a group sftponly
  • add the public_sftp in the sftponly group
  • Change the /etc/ssh/sshd_config and add at the end

    Match group sftponly
        ChrootDirectory %h
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp -u 73
    

This works perfectly fine, except for a script that I need to run from another server using www-data user. When lunching that script that will connect to the sftp server with the www-data user, I am getting:

Write failed: Broken pipe
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]

The home dir of my www-data user is /var/www/ and the rsync scrypt is trying to write in a sub directory from /var/www.

Your Answer

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

Browse other questions tagged or ask your own question.