OpenSSH 是 Linux 系统中常用的 SSH(Secure Shell)服务工具,用于远程登录和文件传输。但在某些场景下,你可能需要将其卸载。以下是针对不同 Linux 发行版的卸载方法。
Ubuntu / Debian 系统
在基于 Debian 的系统中,使用 apt 包管理器卸载 OpenSSH:
sudo apt remove --purge openssh-server openssh-client
sudo apt autoremove
CentOS / RHEL / Fedora 系统
在 Red Hat 系列系统中,使用 yum 或 dnf 卸载 OpenSSH:
# CentOS 7 及以下
sudo yum remove openssh-server openssh-clients
# CentOS 8 / Fedora
sudo dnf remove openssh-server openssh-clients
注意事项
- 卸载 OpenSSH 后将无法通过 SSH 远程连接服务器,请确保你有其他访问方式(如控制台)。
- 部分系统可能将 OpenSSH 作为关键依赖,强制卸载可能导致系统不稳定。
- 如仅需禁用 SSH 服务而非卸载,可使用
systemctl disable ssh并停止服务。