If you’re using Windows Telminal for SSH connection, suggest XShell. If you’ve changed XShell, you don’t have to look at the tutorial.
Send a heartbeat to the service/client on time to address long periods of non-response (non-keyboard input)
Reason
Linux security setup problem: If there is no data in 60s, the SSH connection will be automatically disconnected.
Resolution 1
The service regularly sends a heartbeat to the client Modifys the profile
sudo vim /etc/ssh/sshd_config
Add
ClientAliveInterval 30
ClientAliveCountMax 6
Christian Alive Interval says that every second the server sends a heartbeat to the client, and after he says how many of these heart beats are not responding, he thinks that she’s broken, so the total time allowed for no response is…30*6=180秒
Resolution 2
Client regularly sends a heartbeat to the service
sudo vim /etc/ssh/ssh_config
Add
ClientAliveInterval 30
ClientAliveCountMax 6
Why 30s is set because 30s is good, and you can set 40s, 44s, 59s. But don’t go over 60, it doesn’t make sense.
The document is not the same as the file that was changed by the service and client.
Disconnected connection after too long idle time after ssh login
When we connect to the server through the terminal, when the mouse and keyboard don’t work for long periods of time, the server will automatically disconnect. We need to reconnect. It’s a bit complicated.
Method I
Modify/etc/ssh/sshd_configProfile, findClientAliveCountMax(in minutes) Modify the value you want.
service sshd reload
Method two.
Found the .ssh directory of the user, e.g. root user at:/root/.ssh/, create config file in this directory
vi /root/.ssh/config
Add the following sentence:
ServerAliveInterval 60
Save exit, restart the root user’s shell, and then ssh remote servers are not disconnected for long periods of time. The ssh client should automatically communicate with the ssh server every other time after adding this sentence.
Method III
Modify/etc/profile profile
vi /etc/profile
Add:
TMOUT=1800
It’s gonna take you 30 minutes to get it started.
Method IV
Simulates a keyboard response within the idle time of using expect simulation actions, saves the following codes to xx and executes them with extect:
#!/usr/bin/expect
set timeout 60
spawn ssh user@host
interact {
timeout 300 {send "\x20"}
}
expect xxx
Enter the password by hint, so that every 300 seconds you will automatically type a space (\x20), which can be set at specific intervals.
Method V
If you connect through a tool under windows, you can set the securityCRT: Options – Terminal – Back-off Free in setting how many seconds to send a string, or the NO-OP packageputty:putty –> Connection -> Seconds between keepalives (0 to turn off), default 0, replace with 300.
未经允许不得转载:萌萌Apprentissage » ssh configurationssh connection to prevent automatic disconnection settings
linux One Chinese script
Google shell enable enhanced mode 4 nuclear 16G RAM
Tmux use tutorial
Screen's summary
I'm gonna get you a new one, shell.cloud.google on the line.
Linux Memory Clearing