Install sshfs on an untrusted connection

I am mounting a remote file system using sshfs. If the ssh connection time may cause other applications to freeze (for example, a vim session with only a local file open). It takes ~ 10 minutes to restore the system. This happens even if I mount the remote read-only file system. What for? Is there a way to make sshfs mount so that it does not cause other applications to freeze when using an untrusted connection (for example, wifi)? I do not need something reliable, I just have to be able to view files on a remote computer, it can be read-only.

I am using lubuntu 12.10.

$sshfs -V SSHFS version 2.4 FUSE library version: 2.9.0 fusermount version: 2.9.0 using FUSE kernel interface version 7.18 
+6
source share
3 answers

Use -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3

These ServerAlive settings cause I / O errors after one minute of network outage. Without these parameters, processes that experience I / O hang seem to sleep indefinitely, even after sshfs gets reconnect 'ed.

+7
source

You can play a bit with sshfs options, for example, enable compression, the auto-reconnect flag and nodelay for tcp:

 -C equivalent to '-o compression=yes' -o reconnect -o workaround=LIST [no]nodelaysrv set nodelay tcp flag in ssh (default: off) sshfs server:/srv/homes /mnt/mountpoint -C -o reconnect -o workaround=nodelaysrv 

But what gave me the best results is the use of NFS, I have no lags that I had with sshfs, and pretty standard in the * nix environment, you can export your directory with a read-only option, extra speed. Although note that NFS is not an encrypted protocol.

Server:

 # File: /etc/exports /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) 

Customer:

 mount server:/srv/homes /mnt/mountpoint 
+1
source

Monitoring the remote host and terminating the local sshfs process if you think the remote side is gone. You can do this in many ways. For example, start pinging it as shown in bash:

 mountpoint=~/mnt/google sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=3 user@google.com :/ "$mountpoint" while : do if ping -c 3 google.com then echo "google.com is still up" else # find sshfs pid sshfsPids=$(ps -C sshfs -f | grep "$mountpoint" | grep -v grep | awk '{print $2}' | tr '\n' ' ') kill -SIGTERM "$sshfsPids" fi done 

If you agree to use an external watchdog approach for your connection, consider this project: https://github.com/RuralYak/sshfs-watchdog , which does almost the same thing, but in a more complicated way

+1
source

Source: https://habr.com/ru/post/949601/


All Articles