SSHFS giving error – remote host has disconnected

If you are using SHHFS and getting following error while mounting remote file system over SSH.

remote host has disconnected

To check exact issue, we need to enable debug level and execute command to check log:
( -odebug,sshfs_debug,loglevel=debug )

# sshfs -odebug,sshfs_debug,loglevel=debug user-name@192.168.0.200:/ /mnt/remote-system/ -o sftp_server="/usr/bin/sudo /usr/libexec/openssh/sftp-server"
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
.................
................
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
sudo: sorry, you must have a tty to run sudo
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 2328, received 2212 bytes, in 0.2 seconds
Bytes per second: sent 9903.6, received 9410.1
debug1: Exit status 1
remote host has disconnected

From above debug log, its clear that we are getting “sudo: sorry, you must have a tty to run sudo” error. This indicate the remote file system has denied access for non-tty.

To fix this, go to remote file system and comment “requiretty” parameter in visudo file:

# visudo
...
...
##Defaults    requiretty
...
...

Note: Disabling “ssh hostname sudo <cmd>” is security risk, it will show the password in clear.  You have to run “ssh -t hostname sudo <cmd>”, but SSHFS do not support “-t” parameter.

Leave a Reply

Your email address will not be published.