检查 SSH 服务状态
先确认 SSH 是否真的未安装:
sudo systemctl status ssh
安装 OpenSSH 服务器
更新软件包列表并安装 openssh-server:
sudo apt update sudo apt install openssh-server -y
启动并启用 SSH 服务
安装完成后,启动 SSH 服务并设为开机自启:
sudo systemctl start ssh # 立即启动sudo systemctl enable ssh # 开机自启
如果系统提示 “ssh service 没有被找到”,通常是因为 OpenSSH 服务器(openssh-server)未安装或未正确配置。以下是详细解决方法:
1. 检查 SSH 服务状态
先确认 SSH 是否真的未安装:
bash
复制
sudo systemctl status ssh
如果提示 “Unit ssh.service could not be found”,说明 OpenSSH 服务器未安装。
2. 安装 OpenSSH 服务器
更新软件包列表并安装 openssh-server:
bash 复制 sudo apt update sudo apt install openssh-server -y
3. 启动并启用 SSH 服务
安装完成后,启动 SSH 服务并设为开机自启:
bash 复制 sudo systemctl start ssh # 立即启动 sudo systemctl enable ssh # 开机自启
4. 验证 SSH 服务状态
再次检查状态,确认是否运行正常:
sudo systemctl status ssh
正常输出应显示 “active (running)”。
接着用xshell即可连接到对应端口上线了