This host maintenance note, published on December 1, 2022, is about "how to solve the problem of slow SSH login on CentOS systems". The actual environment and tools involved include CentOS and DNS.
Domain and site configuration
In Linux, reverse DNS lookup for SSH is enabled by default, which consumes a significant amount of time and therefore needs to be disabled. Although `UseDNS yes` is commented out in the configuration file, it is enabled by default.
Data center and resources
If the server was previously configured with dual network cards, there will be a line in this file containing IP addresses that were not used at the time. Simply delete that line.
Matters mentioned in the article
- 1. Disable DNS reverse lookup
- 2. Disable GSS authentication on the server.
- 3. Modify the nsswitch.conf file on the server.
- 4. Modify the resolv.conf file on the server.
- 4.1 Delete all unused IPs in /etc/resolv.conf.
- 4.2 Deleting all nameservers can solve the problem, but the server will then be unable to access the internet.
- 5. Modify the hosts file on the server.
- 6. Enable the IgnoreRhosts parameter on the server.
- 7. Modify the client's hosts file
- 8. Modify the client configuration file ssh_conf (note, not sshd_conf).
Usage Environment
CentOS, DNS.
Key points to check
Parsing changesFirst, determine the record type and target value, then verify the authoritative response and recursive parsing results separately. The TTL of the original record will affect the time it takes for the user to see the new configuration.