I have two users with valid SSH accounts on a server. Both users can login via ssh successfully.

When trying to mount SSHFS, usera can mount with no problems, while userb gets the error:

remote host has disconnected

after entering a valid password.

In the auth.log we get:

Apr 25 19:12:49 Ophelia sshd[26211]: Accepted password for userb from [ip address] port 44609 ssh2
Apr 25 19:12:49 Ophelia sshd[26211]: pam_unix(sshd:session): session opened for user userb by (uid=0)
Apr 25 19:12:49 Ophelia sshd[26240]: subsystem request for sftp
Apr 25 19:12:49 Ophelia sshd[26240]: Received disconnect from [ip address]: 11: disconnected by user
Apr 25 19:12:49 Ophelia sshd[26211]: pam_unix(sshd:session): session closed for user userb

I read that remote host has disconnected can be caused by an invalid sftp-server in /etc/ssh/sshd_config, but the path is set to /usr/lib/openssh/sftp-server which appears valid, and usera can use SSHFS just fine.

The server and client are Ubuntu 10.04.

Any suggestions?


From the OpenSSH FAQ (via knoppixforum.de, English translation here):

sftp and/or scp may fail at connection time if you have shell initialization (.profile, .bashrc, .cshrc, etc) which produces output for non-interactive sessions. This output confuses the sftp/scp client. You can verify if your shell is doing this by executing:

ssh yourhost /usr/bin/true

If the above command produces any output, then you need to modify your shell initialization.

Also try ssh user@host /bin/true.

  • @Indrek How would I alter the shell initialization? And do I alter it on the remote host or local? – Don Rhummy Jan 31 '14 at 23:22
  • Pointing out the possibility of shell init. issues was just what I needed to resolve this issue (turned out I had accidentally stripped the last ' in my .bash_aliases). Thanks! – copper.hat Feb 28 '14 at 6:52
  • if you see something like "LC_ALL: cannot change locale" when performing a simple ssh, run export LC_ALL="" on the local machine before sshfs. Also, make sure there is no Banner defined in /etc/ssh/sshd_config on the remote host (and restart the remote sshd if there was one). – Mat Feb 28 '15 at 19:12

I got it working... The permissions on the user's home folder were set incorrectly. Apparently this doesn't prevent ssh login, but does break sshfs.

  • 23
    so what changes did you have to make to the permissions ? – SMTF Apr 9 '13 at 22:32
  • 1
    What were your permissions before and after you did this? – dranxo Aug 4 '14 at 22:44

Make sure you remove host key from username/.ssh/known_hosts prior to connecting. I had a problem using sshfs and sysrescuecd (every boot gets new keys etc).

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.