以下是在CentOS上优化SSH性能的方法:
/etc/ssh/sshd_config,禁用DNS反向解析和GSSAPI认证:UseDNS noGSSAPIAuthentication noPubkeyAuthentication yesPasswordAuthentication noClientAliveInterval 60ClientAliveCountMax 3/etc/sysctl.conf,增加网络连接相关参数:net.core.somaxconn = 65535net.core.netdev_max_backlog = 65535net.ipv4.tcp_max_syn_backlog = 65535net.ipv4.tcp_tw_reuse = 1sysctl -p 使配置生效。/etc/security/limits.conf,增加以下内容:* soft nofile 65535* hard nofile 65535/etc/ssh/sshd_config 中指定高效加密算法:Ciphers aes128-ctr,aes192-ctr,aes256-ctrMACs hmac-sha2-256,hmac-sha2-512systemctl stop NetworkManagersystemctl disable NetworkManager注意:修改配置前需备份原文件,部分参数(如端口号)需根据实际环境调整,且需重启SSH服务生效。