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 but the client is getting an error, Connection closed by server with exitcode 1

/var/log/auth.log (below) doesn't help much, how can I find out what the error is?

I'm running Ubuntu 10.04.1 LTS

sshd[27236]: Accepted password for theuser from (my ip) port 13547 ssh2
sshd[27236]: pam_unix(sshd:session): session opened for user theuser by (uid=0)
sshd[27300]: subsystem request for sftp
sshd[27236]: pam_unix(sshd:session): session closed for user theuser

Update: I've been prodding this for a while now, I've got the sftp command on another server giving me a more useful error.

Request for subsystem 'sftp' failed on channel 0
Couldn't read packet: Connection reset by peer

Everything I've found on the net suggests this id a problem with sftp-server but when I remove the chroot from sshd config I can access the system. I assume this means sftp-server is accessible and set up correctly.

share|improve this question
What OS are you using? Hard to help otherwise... – sleske Nov 30 '10 at 1:23
Is the user setup with a shell like /sbin/nologin? – Rob Olmos Nov 30 '10 at 1:36
Sorry, Running Ubuntu 10.04.1 LTS – Jake Nov 30 '10 at 1:50
@Rob: the users shell is /bin/bash, set because WinSCP was complaining about an incompatible shell and suggested BASH, after the change it still complains. – Jake Nov 30 '10 at 1:53
Used internal-sftp rather than sftp-server – Jake Nov 30 '10 at 5:18
up vote 1 down vote accepted

The sftp-server is an external binary. It's likely not inside your chroot environment.

If you modify sshd_config to use the internal subsystem (if available) it should start working with chroot.

share|improve this answer
To debug this problem you could have run sshd in foreground and debug mode. – MikeyB Jul 29 '11 at 14:09

I had exactly the same problem. Just like MikeyB suggests, you probably need to change the subsystem to internal-sftp. I changed the following in sshd_config:

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


Subsystem sftp internal-sftp

You also have to change the ForceCommand value in the Match stanza, to something like this:

Match User john-doe
    ChrootDirectory %h
    AllowTCPForwarding no
    X11Forwarding no
    ForceCommand internal-sftp

Atleast that worked for me, hope this helps someone.

share|improve this answer
Oh, I just realized this wasn't really an answer to the question. More of a solution to the error in the logs. – Henko Apr 19 '12 at 11:19
Thank you! I've been searching for a way to debug/fix this issue for about an hour, and your answer was spot on! – Jon-Erik May 21 '14 at 18:24

Just had this myself.

The user simply needed to have SSH permissions.

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.