我在跑步Linux Mint 20.1 Ulyssa(Xfce 4.14.2)我遇到了这个问题,当我通过 Thunar 使用 SFTP/FTP 连接编程时,如果我长时间不通过 SFTP 连接编辑/修改/保存任何文件,它就会断开我的连接,这意味着我需要卸载“目录”然后重新连接。
我连接到 SFTP/FTP 的方式是,我只需从 Thunar 转到Go->Open Location
并在那里写入我的 SFTP/FTP 连接字符串sftp://ip-here/
即可。我目前已将其保存(/已安装?),因此我不再需要编写它,这样我只需双击目录即可打开它。
我试图调整我的 SSH 配置,将时间ServerAliveInterval
和时间增加到ServerAliveCountMax
1 小时,但这似乎没有效果。
我怎样才能增加超时时间以便它不会频繁地断开我与服务器的连接?
服务器的 SSH 设置
# $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
我的电脑的 SSH 设置
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,[email protected]
# 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
答案1
您可能遇到了 NAT 超时或一些奇怪的情况。其他人在评论中提到了 ClientAliveInterval 和 ClientAliveCountMax 的使用。这是我多年来一直使用的配置:
ServerAliveInterval 45
ServerAliveCountMax 60
在服务器端你可以尝试这个:
ClientAliveInterval 60
TCPKeepAlive yes
在另一个 SE 社区中也可以看见这个:
答案2
如果这是 Thonar 的问题,请尝试 SSHFS FUSE 文件系统:
sudo apt-get install sshfs
sshfs-mount -o reconnect user@remotehost:/some/dir/ /home/me/mountpoint/
如果您使用 SSH 密钥进行身份验证,那么-o reconnect
效果会很好。如果不使用,请保留-o reconnect
。
请注意,一旦 sshfs 安装完毕,您就可以像普通文件系统一样使用它,因此无需使用 sftp:// 位置。