AWS EC2 Ubuntu 22.04 LTS 会话超时不起作用(ClientAliveInterval、ClientAliveCountMax)

AWS EC2 Ubuntu 22.04 LTS 会话超时不起作用(ClientAliveInterval、ClientAliveCountMax)

我使用 Ubuntu 安装了 AWS EC2 实例:

ubuntu@ip-aaa-bbb-ccc-ddd:~$ lsb_release -ds
Ubuntu 22.04.3 LTS

我使用以下简单教程来设置ClientAliveIntervalClientAliveCountMax

https://www.tutorialspoint.com/how-to-increase-ssh-connection-timeout-in-linux

https://www.tecmint.com/increase-ssh-connection-timeout/

cat /etc/ssh/sshd_config

给出:

... ^^ there's more above

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
ClientAliveInterval 360
ClientAliveCountMax 10
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

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

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

重要事项:

TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
ClientAliveInterval 360
ClientAliveCountMax 10

编辑并保存文件后,/etc/ssh/sshd_config我执行sudo service ssh restart并关闭了 SSH 会话(我也尝试过sudo systemctl reload sshd像在其他教程中一样),但是:

重新连接并等待 10 多分钟后,输入任何字符,我的 SSH 客户端告诉我我的连接已超时(10 分钟似乎是默认的 AWS 设置,但我想要一小时 = 10 乘以 360 秒)。

问题:

怎么了?

如何让会话超时起作用服务器端对于 AWS EC2 Ubuntu 22.04 LTS,即没有任何客户端会话超时属性(我从多个地方连接,所以我想避免这种情况)。

相关内容