本文最后更新于 2025-11-06,文章内容可能已经过时。

诊断步骤

  1. 查看详细的错误日志

# 查看SSH服务的详细错误信息
journalctl -xeu sshd.service

# 或者查看最近的系统日志
journalctl -u sshd --since "5 minutes ago"

2. 检查SSH配置文件语法

# 检查SSH配置文件语法
sshd -t

# 查看SSH配置文件
cat /etc/ssh/sshd_config | grep -v "^#" | grep -v "^$"

3.检查端口是否被占用

ss -ntulp  |  grep  22
# 如果被占用,杀死占用进程或修改SSH端口

4.检查SEliunx状态

# 检查SELinux状态
getenforce

# 如果SELinux是Enforcing模式,尝试暂时禁用
setenforce 0

5.关闭防火墙

systemctl status  firewalld  #查看状态
systemctl stop  firewalld   #关闭防火墙

使用vnc控制台操作

下边是我遇到的问题

这个错误表明SSH服务编译时使用的OpenSSL版本与当前系统中安装的OpenSSL版本不匹配。
具体来说,sshd是使用OpenSSL版本36800818构建的,但当前系统安装的OpenSSL版本是36260626。

这通常是因为系统更新了OpenSSL库,但没有重新编译或更新sshd服务。

解决方案:

强制重新安装所有相关包

# 清理并重新安装所有 SSH 和 OpenSSL 相关包
yum remove openssh-server openssh-clients openssh -y
yum remove openssl openssl-libs -y

# 清理残留配置
rm -rf /etc/ssh/*

# 重新安装
yum install openssl openssl-libs -y
yum install openssh-server openssh-clients -y


# 启动 SSH 服务
systemctl start sshd
systemctl enable sshd
systrmctl status  sshd

检查ssh配置

# 检查当前 SSH 配置
cat /etc/ssh/sshd_config | grep -E "(PasswordAuthentication|PermitRootLogin|Port)"

# 确保配置正确(如果不是这些,修改它们)
PasswordAuthentication yes  允许使用密码
PermitRootLogin yes   允许root用户使用密码登录
Port 22