# Loss of SSHFS mount after 3-5 minutes ?



## Spartrekus (Apr 24, 2019)

Hello,

On a BSD server running with sshd(8) enabled, FreeBSD clients will lose after 5 minutes this sshfs(1) connection. sshfs(1) mount is working but it doesn't after given time.

How to make sure that sshfs(1) stay mounted?
thank you


----------



## SirDice (Apr 24, 2019)

Is there a stateful firewall in between? I'm thinking a firewall state is timing out when there's no traffic going back and forth (idle connection). With a regular ssh(1) client you can enable a periodic "keep-alive" that sends noop packets. This is usually enough for the firewall to keep its state and the connection alive. I'm sure sshfs(1) has a similar setting.


----------



## drhowarddrfine (Apr 24, 2019)

Losing is spelled l-o-s-i-n-g


----------



## SirDice (Apr 24, 2019)

Probably not entirely politically correct these days but I learned this bridge 30-something years ago and it's still stuck in my head: Loose women make you lose money. This one sentence shows the difference between 'loose' and 'lose'.


----------



## D-FENS (Apr 24, 2019)

SSH has a keep alive parameter. Try to use that. I think SSHFS should be able to set it.



Spartrekus said:


> Hello,
> 
> On a BSD server running with sshd(8) enabled, FreeBSD clients will lose after 5 minutes this sshfs(1) connection. sshfs(1) mount is working but it doesn't after given time.
> 
> ...


----------



## Spartrekus (Apr 24, 2019)

note: keep alive parameter did not help at all in sshd config.

192.168.50.x
they are on same router

btw:
The client running devuan keeps it alive somehow and mounted.


----------



## Spartrekus (Apr 24, 2019)

SirDice said:


> Is there a stateful firewall in between? I'm thinking a firewall state is timing out when there's no traffic going back and forth (idle connection). With a regular ssh(1) client you can enable a periodic "keep-alive" that sends noop packets. This is usually enough for the firewall to keep its state and the connection alive. I'm sure sshfs(1) has a similar setting.


it seems that it comes from FreeBSD clients, because the raspbian and devuan x86 keep it mounted.


----------



## Spartrekus (Apr 24, 2019)

seems that it is not first time this issue (2009)








						ssh drops client after a few minutes
					

im sure this is a simple fix but i can't find anything beyond what i have done and hoping that some has some other input im not seeing.  client drops after a few minutes of inactivity.  changed /etc/ssh/sshd_config file multiple times  ClientAliveInterval 0 (also have tried 300 and...




					forums.freebsd.org
				





```
#    $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
#    $FreeBSD: head/crypto/openssh/sshd_config 338561 2018-09-10 16:20:12Z des $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# Note that some of FreeBSD's defaults differ from OpenBSD's, and
# FreeBSD has a few additional options.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile    .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
#PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no

# X11Forwarding no

#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes

TCPKeepAlive yes

#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#UseBlacklist no
#VersionAddendum FreeBSD-20180909

# no default banner path
#Banner none

# override default of no subsystems
Subsystem    sftp    /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#    X11Forwarding no
#    AllowTcpForwarding no
#    PermitTTY no
#    ForceCommand cvs server
```


----------



## D-FENS (Apr 24, 2019)

Also the SSH client can control the keep alive behavior.
Check the following options in your SSH client configuration:

ServerAliveCountMax
ServerAliveInterval
TCPKeepAlive
ssh_config(5)


----------



## D-FENS (Apr 24, 2019)

I use SSHFS links on both server and client FreeBSD 12. I have no disconnect problems whatsoever. I have this in my ~/.ssh/config:

```
% cat ~/.ssh/config | head
Host *
        ServerAliveInterval 60
        ServerAliveCountMax 320
        IdentitiesOnly      yes
```


----------

