First i am going to explain what I'm trying to do. I have set up a webserver running ubuntu server on top of vmware-esxi. I want to use SFTP over SSH to upload my website's code. We did this in a php class I took.

I followed this guide.

So I have a user named sftpuser and a group called sftp and when I try to connect it gives the error:

packet_write_wait: Connection to x.x.x.x port 22: Broken pipe

My ssh config looks this at the bottom, the rest is unchanged

ClientAliveInterval 20
ClientAliveCountMax 5

TCPKeepAlive yes

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

I'm new to linux so I'm unsure what the cause could be. Thanks.


The error in /var/log/auth.log is

fatal: bad ownership of chroot directory component "/var/www"
  • 1
    Can you give the content of /var/log/auth.log from the server? – ob2 Jan 15 at 9:17

Ok the issue seems to be I did not have permissions for /var/www, when I changed the permissions as shown in the guide I did that for /var/www/html. So when I ran this

cd /var/www
chown root:sftp .
chmod 755 .
chown -R sftpuser:sftp *

it worked. I also ran it again on /var/www/html just to be sure.

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.