SSH connection stuck solution

Time:2021-10-13

problem

Both the local machine and the server are on the same intranet and can ping each other. However, when the local machine SSH connects to the server remotely, the terminal input command will always get stuck.
It was tested that while Caton was on the Internet, they could not Ping each other when losing packets, but both had no problem accessing the Internet.

Reason 1: the ssh server enables DNS query by default:UseDNS=yes

WhenUseDNSWhen the option is on, the client attempts to log in to the ssh server. The server first reversely queries the host name of the client by DNS PTR according to the IP address of the client, and then queries the DNS forward a record according to the queried host name of the client to verify whether it is consistent with its original IP address, which is a measure to prevent the client from cheating, But generally, we don’t have PTR records for dynamic IP. Turning on this option is just a waste of time. It’s better to turn it off.

vim /etc/ssh/sshd_config
   UseDNS=no
   #Add this option
   service sshd restart
   #Restart sshd service
Reason 2: if GSSAPI login authentication mode is enabled on ssh server:GSSAPIAuthentication=yes, not enabled by default

GSSAPI is the public security transaction application program interface (GSS-API)
Whether GSSAPI authentication allows user authentication based on GSSAPI. The default value is “no”. It is only used for ssh-2
Whether gssapicleanupcredentials automatically destroys the user credential cache after the user logs out. The default value is “yes”. It is only used for ssh-2
If the server turns on the authentication mechanism, but the client does not use the authentication mechanism, the authentication process will be delayed

vim /etc/ssh/sshd_config
   GSSAPIAuthentication=no
   #Turn off GSSAPI authentication mechanism
   service sshd restart
   #Restart sshd service

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]