sshfs - 'read: Connection reset by peer'

04 Apr 2017

sshfs will give the error read: Connection reset by peer whenever ssh refuses a request. To debug this issue, try the parameters that you gave to sshfs with just ssh first. Having the wrong port number, user, lacking the correct identity file for your host are common problems that can cause this error.

When running sshfs read: Connection reset by peer can be caused by running sshfs as root since the default identity file will not be your user's identity file, and you will need to specify the identity file for that host in ~/.ssh/config and then point sshfs to the config. For example the myserver entry could look like this:

Host myserver
    HostName 192.168.1.3
    IdentityFile /home/myuser/.ssh/id_myserver
    Port 2222
    User myuser

Note that the config does not evaluate ~, so a full path will need to be specified for IdentityFile.

If you are relying on ~/.ssh/config for extra options, when running as sudo sshfs will instead look at /root/.ssh/config. You can use the -F option to specify the configuration path:

sudo sshfs -F ~/.ssh/config myserver: /mymountpoint

If this sshfs command is instead in /etc/fstab, then you will need to use the full path to the user's configuration, since the user's shell is not there to do expansion on the home directory(~).

Note

sshfs uses FUSE, which stands for Filesystem in Userspace. It's meant to be able to run as a user, so sudo is not completely necessary. You can modify the permissions of the target directory to allow the current user to mount it. It's as easy as chown myuser:myuser /mymountpoint.