在 Ubuntu 上卸载 SSH 服务(通常是 openssh-server),可以按下面的步骤操作:
先停止正在运行的 SSH 服务:
sudo systemctl stop ssh
(某些旧版本可能是 sudo service ssh stop)
sudo apt remove openssh-server
如果你想彻底清除配置:
sudo apt purge openssh-server
sudo apt autoremove
dpkg -l | grep openssh
如果没有 openssh-server 相关条目,说明已卸载。
也可以检查端口:
sudo systemctl status ssh
应提示 Unit ssh.service could not be found 或服务已停止。
不想卸载,只关闭开机启动:
sudo systemctl disable ssh
如果你是因为安全问题 / 服务器被入侵 / 无法登录等原因要卸载 SSH,也可以告诉我具体场景,我可以给你更合适的建议。