sshfs is failing with "remote host has disconnected"
I'm running sshfs with the following:
sshfs [email protected]:/var/www/myapp /home/basicuser/code -o sftp_server="/usr/bin/sudo /usr/libexec/openssh/sftp-server"
I have also created RSA keys so I can log in via ssh without password prompt (I tested this and it works).
I have also added the user to the sudoers file to run the sftp-server without a password:
basicuser ALL=(ALL) NOPASSWD: /usr/libexec/openssh/sftp-server
What could be causing this error? How do I figure that out?
Edit
I am trying to mount a folder on the local computer from the remote server. On the remote server, only root has read/write permissions to that folder.
Remote folder: /var/www/myapp (is root only read/write)
Solution 1:
You get a lot more information about the failure if you run sshfs as:
sshfs -odebug,sshfs_debug,loglevel=debug user@host ...
Usually this will give you something a lot more helpful to debug the problem.
Solution 2:
It was requiring tty (this basically means something cannot be run in the background, but needs an active terminal window to run). So I added the following to /etc/sudoers
(edited by doing visudo
):
Defaults:basicuser !requiretty
I want it to not require tty only for that one command, but it may not be possible to do that: https://unix.stackexchange.com/a/80159