Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up sftp server with open-ssh to store some files but when I try to connect it I just get "Connection closed by server with exitcode 1" in FileZilla. It can't be just wrong username or password because i've already checked it several times and even changed it. Here are my sshd_config settings:

Subsystem sftp internal-sftp
UsePAM yes
"Match group sftponly
ChrootDirectory /var/www
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp"
share|improve this question
The Match block must not be enclosed in double-quotes. Is it a typo? – dawud Aug 11 '13 at 11:52
What do your server logs say ? – Iain Aug 11 '13 at 12:30
Yeah, that problem was caused by quotes. I just pasted the code from one guy's tutorial on youtube. Thanks! – Dmitry Mikhaylov Aug 11 '13 at 14:14
up vote 1 down vote accepted

As dawud says there should be no " around the match block, whilst sshd is happy to start without complaint, with the " when you try to connect it drops the connection.

If the " are a typo in your question then there are other things to check. First check you logs and see if there are any relevant messages that are useful. Unfortunately without knowing what OS the server is running we can't be much more specific than that about which ones.

Check that the ownership and permissions on /var and /var/www are suitable for a chroot environment.

It could be SElinux, again check your logs (audit.log perhaps) for suspicious avc: denied messages. There are a couple of SELinux boolean values that may be helpful if this is the case, ssh_chroot_manage_apache_content and ssh_chroot_full_access. The former would seem most appropriate try

setsebool ssh_chroot_manage_apache_content true

and if this works make it permanent with

setsebool -P ssh_chroot_manage_apache_content true
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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