在 CentOS 中“卸载 SSH 服务”通常指的是卸载 OpenSSH 服务端(sshd)。操作前请特别注意:如果你的服务器只有远程 SSH 连接,卸载 sshd 会导致你无法再远程登录,请务必确认有控制台/物理机或其他管理方式。
rpm -qa | grep ssh
常见包名:
openssh-server(SSH 服务端,提供 sshd)openssh-clients(SSH 客户端)opensshsystemctl stop sshd
systemctl disable sshd
yum remove openssh-server
或(CentOS 8+):
dnf remove openssh-server
如果连客户端也要卸载:
yum remove openssh openssh-server openssh-clients
rpm -qa | grep ssh
systemctl status sshd # 应提示未找到
如果你只是不想用 SSH,但不想彻底删除:
systemctl stop sshd
systemctl disable sshd
这样系统仍保留软件,可随时重新启用。
yum install openssh-server
systemctl enable --now sshd
⚠️ 重要提醒
openssh-server 不会影响系统本身,但会失去远程管理能力如果你是要彻底最小化系统、替换成其他远程方式(如 dropbear),可以告诉我使用场景,我给你更合适的方案。