0

I want an user to have access to /var/www/domain.com/public_html so I followed this tutorials, but with my modifications so I can have my users upload directly to their domains:

https://www.linode.com/docs/tools-reference/tools/limiting-access-with-sftp-jails-on-debian-and-ubuntu

https://bensmann.no/restrict-sftp-users-to-home-folder/

So, I'm on ubuntu 14.04, and this is what I did:

In my /etc/ssh/sshd_config

# Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

#...
UsePAM yes

Match group www-data
    ChrootDirectory %h
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp

Also created a user called username and run this commands:

sudo usermod username -g www-data
sudo usermod username -d /var/www/domain.com
sudo usermod username -s /bin/false
sudo chown root:root /var/www/domain.com
sudo chmod 0755 /var/www/domain.com
sudo chown -hR username:www-data /var/www/domain.com/public_html
sudo service ssh restart

When I try to sftp I get this error

Write failed: Broken pipe Couldn't read packet: Connection reset by peer

What I am missing?

1
  • also I have checked that all the folders in /var/www/domain.com are chowned to root:root and 755 permissions
    – xavip
    Jul 10 '15 at 18:03
0

Finally I've checked again the permissions and I had them wrong I just chown root:root and chmod 755 all the path to /var/www/domain.com and now it's working great

Your Answer

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.