openSSH connection reset by peer

0

I am trying to upload files to a server I have been configuring using sftp. Therefore I am using the internal-sftp server of openSSH Server.

I tried to add following code to /etc/ssh/sshd_config

Match User web
   ChrootDirectory /var/www
   ForceCommand internal-sftp

But I always get the error Connection reset by peer. If I leave the code out, it works – but I am of course in the wrong directory (/home/web). What's the problem here and what can I do to achieve what I described?

Deproblemify

Posted 2015-10-23T17:20:09.533

Reputation: 128

Answers

2

I answered this on Unix Stackexchange. This was answered many times, but I can't find it now. The answer is RTFM.

Short story long: From man sshd_config you can get this line:

ChrootDirectory

Specifies the pathname of a directory to chroot(2) to after authentication. All components of the pathname must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directory.

Which provides explanation for your error message. Fixing the ACLs on the path will solve your issue.

There is also error in your server log (good place to start investigating such issues) describing this problem.

Jakuje

Posted 2015-10-23T17:20:09.533

Reputation: 7 981

Thanks, I will take a look at that tomorrow. And yes I know it's been answered many times – I always do a deep search first – but when working with a server for hours and hours you sometimes get to a point where you are just to frustrated to search any more. – Deproblemify – 2015-10-23T20:57:03.920

What I have done in the end was to set the home directory of the user web to /var/www since the user didn't have any other permissions anyways – Deproblemify – 2015-10-24T09:10:11.200