Solve the problem that Alibaba Cloud SSH remote connection will be disconnected after a short time

Solve the problem that Alibaba Cloud SSH remote connection will be disconnected after a short time

Problem Reproduction

Alibaba Cloud Server, using Finalshell remote connection, no task exceptions occurred during the operation. As long as there is no operation during the remote connection, the server will be disconnected after a while. If you cannot enter commands in the input box, you need to close the current window and reconnect.

Problem Analysis

Generally, for this kind of problem, we first check whether there is a problem with finalshell itself. We can open xshell and remotely connect to Alibaba Cloud, and find that xshell is still disconnected. Then we have ruled out the possibility of software problems. Next, we need to check the ssh service to see if there are some restrictions in the sshd configuration file.

Problem Solving

1. Open the sshd configuration file

[root@ecs-c13b ~]# vim /etc/ssh/sshd_config

Modify the following two lines:

insert image description here

2. Modify the following parameters

ClientAliveInterval 30 #The client sends a heartbeat data to the service every 30 seconds

ClientAliveCountMax 1800 # The server will automatically disconnect the client if there is no response for a certain number of seconds

3. Restart the service:

insert image description here

Replenish

After solving this problem, I remembered another interesting parameter
LoginGraceTime 2m
This parameter means:
(1) Grace means how many seconds the system gives to log in.
(2) After the user connects to the SSH server, a screen will appear for entering the password.
(3) If the SSH server fails to connect successfully within a certain period of time, the connection will be disconnected. If no unit is given, the time is assumed to be seconds.

In the company, we often encounter a situation where you use ssh to connect remotely to an IP and are ready to enter your username and password. Before you enter them, the connection remains connected. Or you have entered your username and password but have not yet pressed Enter. At this time, your work is interrupted and someone comes to chat with you, so the connection will be waiting. This parameter means how long to wait before the connection is automatically closed.

Summarize

This article mainly explains that when you connect to the server remotely through ssh, if there is a situation where the connection is disconnected after a short period of time without any operation, you can adjust the parameters according to this article to extend the time.

This is the end of this article about how to solve the problem of Alibaba Cloud SSH remote connection being disconnected after a short time. For more relevant Alibaba Cloud SSH remote connection content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Python uses SSH to remotely connect to redis
  • Python3 SSH remote connection server method example
  • How to solve the problem of Linux ssh remote connection disconnection

<<:  Mysql index types and basic usage examples

>>:  Detailed explanation of the loop form item example in Vue

Recommend

Steps to install cuda10.1 on Ubuntu 20.04 (graphic tutorial)

Pre-installation preparation The main purpose of ...

How to Fix File System Errors in Linux Using ‘fsck’

Preface The file system is responsible for organi...

How to upload projects to Code Cloud in Linux system

Create a new project test1 on Code Cloud Enter th...

Detailed example of locating and optimizing slow query sql in MySQL

Table of contents 1. How to locate and optimize s...

MySQL detailed explanation of isolation level operation process (cmd)

Read uncommitted example operation process - Read...

How to load the camera in HTML

Effect diagram: Overall effect: Video loading: Ph...

Steps for importing tens of millions of data into MySQL using .Net Core

Table of contents Preliminary preparation Impleme...

HTML/CSS Basics - Several precautions in HTML code writing (must read)

The warning points in this article have nothing t...

The final solution to Chrome's minimum font size limit of 12px

I believe that many users who make websites will ...

Vue implements start time and end time range query

This article shares with you how to query the sta...

Analysis of Hyper-V installation CentOS 8 problem

CentOS 8 has been released for a long time. As so...

3 ways to correctly modify the maximum number of connections in MySQL

We all know that after the MySQL database is inst...

Insufficient memory problem and solution when docker starts elasticsearch

question Insufficient memory when docker installs...