SFTP/FTP connection timeouts when left unused for few minutes

I am running Linux Mint 20.1 Ulyssa (Xfce 4.14.2) and I have this issue where I am programming something using SFTP/FTP connection through Thunar, and if I stay too long without editing/modifying/saving any files through SFTP connection, it will disconnect me, meaning I need to unmount the "directory" and then connect again.

The way I have connected to my SFTP/FTP is that I simply just go from my Thunar to Go->Open Location and write my SFTP/FTP connection string there sftp://ip-here/. I have it saved(/mounted?) currently, so I don't need to write it anymore, making it easier for me to just double-click the directory to open it.

I have tried to tweak my SSH config increasing the ServerAliveInterval and ServerAliveCountMax to 1 hour, but this seems to have no effect.

How can I increase the timeout time, so it would not disconnect me from the server too often?

Server's SSH settings

# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ # 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. #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 prohibit-password #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #PubkeyAuthentication yes # Expect .ssh/authorized_keys2 to be disregarded by default in future. #AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #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 # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes 

My computer's SSH settings

Host * # ForwardAgent no # ForwardX11 no # ForwardX11Trusted yes # PasswordAuthentication yes # HostbasedAuthentication no # GSSAPIAuthentication no # GSSAPIDelegateCredentials no # GSSAPIKeyExchange no # GSSAPITrustDNS no # BatchMode no # CheckHostIP yes # AddressFamily any # ConnectTimeout 0 # StrictHostKeyChecking ask # IdentityFile ~/.ssh/id_rsa # IdentityFile ~/.ssh/id_dsa # IdentityFile ~/.ssh/id_ecdsa # IdentityFile ~/.ssh/id_ed25519 # Port 22 # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc # MACs hmac-md5,hmac-sha1, # EscapeChar ~ # Tunnel no # TunnelDevice any:any # PermitLocalCommand no # VisualHostKey no # ProxyCommand ssh -q -W %h:%p gateway.example.com # RekeyLimit 1G 1h SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes ServerAliveInterval 300 ServerAliveCountMax 3 
9

2 Answers

You could be hitting a NAT timeout or something strange. Others noted the use of ClientAliveInterval and ClientAliveCountMax in the comments. This is what my config has been using for years:

ServerAliveInterval 45 ServerAliveCountMax 60 

On the server side you could try this:

ClientAliveInterval 60 TCPKeepAlive yes 

Also see this in another SE community:

If it is a problem with Thonar, then try the SSHFS FUSE filesystem:

  • sudo apt-get install sshfs
  • sshfs-mount -o reconnect user@remotehost:/some/dir/ /home/me/mountpoint/

If you use SSH keys for authentication then -o reconnect will work great. If not, leave off -o reconnect.

Note that once sshfs has mounted you can use it like a normal filesystem, so no need to use sftp:// locations.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like