One user can use SSHFS, other user gets “remote host has disconnected”

opensshsshsshfs

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?

Best Answer

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.

Related Question