跳到主要内容

设置

如何设置工作目录检测?

当您从终端界面切到文件管理时,文件管理器会自动打开终端当前的目录,此功能需要我们自行配置,下面为配置步骤

  1. Bash
vim ~/.bash_profile
export PS1="$PS1\[\e]7;CurrentDir="'$(pwd)\a\]'
  1. Zsh
vim ~/.zshrc
precmd () { echo -n "\x1b]7;CurrentDir=$(pwd)\x07" }

如何在边栏中隐藏IP地址?

在设置对话框中,只需点击切换按钮,如下图所示

如何让主机一直保持连接?

Linux SSH会在一段时间后关闭连接

什么是空闲SSH会话?

当主机和客户端之间建立了ssh连接,但用户在该连接上没有活动,就会被当作空闲。在这里,尽管ssh会话没有处于卡住状态。您可以列出所有活动ssh连接,然后检查单个源主机的空闲时间。

断开空闲SSH会话的诀窍是使用以下两个具有适当值的参数来实现这两种情况,即断开空闲SSH会话,并确保您的SSH会话在空闲时不会断开连接

  1. ClientAliveInterval
  2. ClientAliveCountMax

sshd_config的手册页中的描述

ClientAliveCountMax
Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached
while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client
alive messages is very different from TCPKeepAlive. 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 is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 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.

断开空闲的SSH会话(ssh在一段时间后关闭连接)

要断开空闲的SSH会话,即在一段时间后关闭连接,请确保ClientAliveCountMax为0。因为当0时,如果客户端在ClientAliveInterval提供的一段时间内处于非活动状态,sshd将不会发送客户端活动消息,并在某个时间后关闭ssh连接。

保持空闲的SSH会话处于活动状态

在客户端节点上的sshd_config中使用TCPKeepAlive来确保连接一直活动。sshd_config的手册页中的描述:

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.
On the other hand, if TCP keepalives are not sent, sessions may hang indefinitely on the server, leaving "ghost" users and consuming server
resources.

The default is yes (to send TCP keepalive messages), and the server will notice if the network goes down or the client host crashes. This avoids in‐
finitely hanging sessions.

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

Nex终端支持TCP KeepAlive功能,允许您直接在设置对话框中方便地设置Keep Alive活动间隔。