You are not logged in.

#1 2016-09-28 15:25:55

schwim
Member
From: Coastal VA, Murica
Registered: 2015-09-29
Posts: 342
Website

SSHFS - Can I modify the timeout?

Hi there folks!

I use SSHFS to work on websites, allowing me to skip the upload portion of my development time, since I like to make small changes and see how they work.  During my work day, I'll take breaks to do other things, make a phone call, hug a stuffed animal, shave the cat.  Just the normal stuff.

If I'm working on my laptop, which is running the latest Ubu, I can come back and go back to work on my remote files with no issue.  On my BL install, my file manager is frozen and my text editor is letting me know that the files I'm working on are no longer found on the disk.

I've googled but I'm not finding the answer so I'm asking the gurus(you guys); Is there a way to modify the time in which my BL install decides to drop this connection?  I don't need it open forever but would like it to last a little bit longer.

Thanks for your time!


Schw.im! A social site with an identity crisis.

Offline

#2 2016-09-28 17:05:53

nobody
The Great
Registered: 2015-08-10
Posts: 3,655

Re: SSHFS - Can I modify the timeout?

Two things.

Server side: Configure these two options to reasonably high values:

ClientAliveCountMax
              Sets the number of client alive messages (see below) which  may
              be  sent  without  sshd(8) receiving any messages back from the
              client.  If this threshold is reached while client  alive  mes‐
              sages  are  being sent, sshd will disconnect the client, termi‐
              nating the session.  It is important to note that  the  use  of
              client  alive  messages  is  very  different  from TCPKeepAlive
              (below).  The  client  alive  messages  are  sent  through  the
              encrypted channel and therefore will not be spoofable.  The TCP
              keepalive option enabled by  TCPKeepAlive  is  spoofable.   The
              client  alive  mechanism  is valuable when the client or server
              depend on knowing when a connection has become inactive.

              The default value is 3.  If ClientAliveInterval (see below)  is
              set  to  15,  and  ClientAliveCountMax  is left at the default,
              unresponsive SSH clients will be  disconnected  after  approxi‐
              mately 45 seconds.

       ClientAliveInterval
              Sets  a  timeout interval in seconds after which if no data has
              been received from the client,  sshd(8)  will  send  a  message
              through  the  encrypted  channel to request a response from the
              client.  The default is 0, indicating that these messages  will
              not be sent to the client.

and also

TCPKeepAlive no 

As sshfs is SSH and thus bound to the rules of ssh_config, configure these on the client side:

ServerAliveCountMax
              Sets the number of server alive messages (see below) which may be sent without ssh(1) receiving any messages back from the server.   If  this
              threshold  is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session.  It is impor‐
              tant to note that the use of server alive messages is very different from TCPKeepAlive (below).  The server alive messages are  sent  through
              the  encrypted channel and therefore will not be spoofable.  The TCP keepalive option enabled by TCPKeepAlive is spoofable.  The server alive
              mechanism is valuable when the client or server depend on knowing when a connection has become inactive.

              The default value is 3.  If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if the
              server becomes unresponsive, ssh will disconnect after approximately 45 seconds.

       ServerAliveInterval
              Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted
              channel to request a response from the server.  The default is 0, indicating that these messages will not be sent to the server.

TCPKeepAlive
              Specifies whether the system should send TCP keepalive messages to the other side.  If they are sent, death of the connection or crash of one
              of  the  machines  will be properly noticed.  However, this means that connections will die if the route is down temporarily, and some people
              find it annoying.

              The default is ``yes'' (to send TCP keepalive messages), and the client will notice if the network goes down or the remote host  dies.   This
              is important in scripts, and many users want it too.

              To disable TCP keepalive messages, the value should be set to ``no''.

in a similar fashion in your local ~/.ssh/config for your file server host.

Then, according to the sshfs man page, there are several interesting options:

       -o reconnect
              reconnect to server

       -o delay_connect
              delay connection to server

       -o cache_timeout=N
              sets timeout for caches in seconds (default: 20)

       -o cache_X_timeout=N
              sets timeout for {stat,dir,link} cache

By putting all these things together, I'm sure you cook something up that works for you.

P.S. man pages: sshd_config, ssh_config, sshfs.

Offline

Board footer

Powered by FluxBB