1. SSH 常见错误

1.1. 登录失败


ssh: connect to host localhost port 22: Connection refused 问题

错误原因:

1.sshd 未安装 2.sshd 未启动 3.防火墙 4.需重新启动ssh 服务 1、检查 /etc/hosts.deny 和 /etc/hosts.allow 里面是否屏蔽了某些帐户; 2、删除 ~/.ssh/known_hosts 里面的相关服务器条目试一下; 3、Debian 上 /var/run/sshd/ 的所属问题导致 SSH 不能启动; 4、在某些发行版上升级 glibc 或 openssl 等软件包以后需要重启一下 sshd; 5、由于 ssh 试探或者 ssh 连结数太多,/etc/ssh/sshd_config 里面的 MaxStartups 默认参数配置不够用; 6、欢迎补充 …

解决方法:

1.确定安装sshd 2.重新启动sshd 3.检查防火墙设置,关闭防火墙

1.2. ssh 登录卡死


36 [    0.000000] ACPI Warning: Invalid length for Pm1aControlBlock: 32, using default 16 (20090903/tbfadt-607)                                                                           
37 [    0.000000] ACPI Warning: Invalid length for Pm2ControlBlock: 32, using default 8 (20090903/tbfadt-607)
0.848053] ACPI Warning for \_SB_._OSC: Return type mismatch - found Integer, expected Buffer (20090903/nspredef-1006)   

可能是主板故障导致的ssh执行卡 重装系统后及OK了

1.3. SSH登录过程很慢

  1. GSSAPIAuthentication导致认证慢
#cat /etc/ssh/ssh_config |grep GSSAPIAuthentication
GSSAPIAuthentication no

2 UseDNS导致解析超时卡

无法解析主机名导致,配置主机名解析或者禁用该功能 登陆的时候客户端需要对服务器端的IP地址进行反解析,如果服务器的IP地址没有配置PTR记录,那么就容易在这里卡住了

debug2: key: /root/.ssh/identity ((nil))
debug2: key: /root/.ssh/id_rsa (0x7f5fa5519cb0)
debug2: key: /root/.ssh/id_dsa ((nil))
等待中...........
debug1: Authentications that can continue: publickey,password

修改SSHD端UseDNS为no后重启sshd服务

[root@localhost ~]# cat /etc/ssh/sshd_config |grep UseDNS
#UseDNS yes
UseDNS no

批量修复命令

sed -i -e 's/UseDNS yes/UseDNS no/g' -e 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/sshd_config && systemctl restart sshd.service
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2022-01-02 09:59:36

results matching ""

    No results matching ""