Ubuntu重装系统后ssh连接不上(遇到 “Unit ssh.service not found“ 错误)

重装系统时不知道为什么SSH 服务未安装, 以下是解决方案:

先检查ssh服务安装没安装

bash 复制代码
sudo systemctl status ssh      # Ubuntu/Debian

如果 systemctl 找不到服务,可能是 SSH 未安装:

bash 复制代码
sudo apt update
sudo apt install openssh-server
sudo systemctl start ssh      # 启动服务
sudo systemctl enable ssh     # 开机自启

安装一下服务,然后ssh即可连接成功