This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3749|Reply: 0

[windows] Windows resolves an issue where SSH to Linux automatically disconnects after a while

[Copy link]
Posted on 9/20/2024 1:54:46 PM | | | |
Requirements: Now Windows systems have built-in OpenSSH programs, which can be connected to remote Linux servers through ssh commands, but if you do not operate the terminal for a long time, it will cause fake death and unresponsiveness, and then disconnect.

For Windows, the default installation folder is %systemdrive%\Windows\System32\openssh, as shown in the image below:



solution

Set up an OpenSSH configuration file, and in Windows, the OpenSSH client (ssh) reads configuration data from the configuration file in the following order:

ssh.exe start by using the parameter -F, specifying the path to the configuration file and the entry name for that file.
The user's profile is located at %userprofile%\.ssh\config
The system-wide profile is located at %programdata%\ssh\ssh_config

So, newssh_configfile (e.g., C:\ProgramData\ssh folder), configured as follows:

ServerAliveInterval 50: This setting specifies that the SSH client will send a heartbeat packet (SSH message with no data) to the server every 50 seconds to ensure that the connection remains active. This is useful to prevent some intermediary devices, such as routers or firewalls, from disconnecting due to prolonged inactivity. If the server does not respond to this heartbeat packet, the client continues to send.
ServerAliveCountMax 3: This setting specifies the maximum number of times an SSH client will attempt to send heartbeat packets to the server without any data exchange. If you still don't receive a response from the server after reaching the maximum number of times, the connection is considered broken or untrustworthy and the connection is automatically closed. In this example, if the client sends heartbeat packets 3 times in a row without receiving a response from the server, then it will disconnect.

Then, restart the terminal window.

Reference:The hyperlink login is visible.





Previous:.NET/C# calls the ClamAV open source virus scanning service
Next:VS 2022 Package Management Console Chinese garbled solution
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com