温馨提示×

centos如何卸载ssh服务

小樊
41
2026-09-05 20:36:18
栏目: 智能运维

在 CentOS 中“卸载 SSH 服务”通常指的是卸载 OpenSSH 服务端(sshd)。操作前请特别注意:如果你的服务器只有远程 SSH 连接,卸载 sshd 会导致你无法再远程登录,请务必确认有控制台/物理机或其他管理方式。


一、查看是否已安装 SSH 服务

rpm -qa | grep ssh

常见包名:

  • openssh-server(SSH 服务端,提供 sshd)
  • openssh-clients(SSH 客户端)
  • openssh

二、停止 SSH 服务

systemctl stop sshd
systemctl disable sshd

三、卸载 SSH 服务(服务端)

CentOS 7 / 8 / Stream(使用 yum/dnf)

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 不会影响系统本身,但会失去远程管理能力
  • 云服务器请使用 VNC / 控制台操作
  • 若误删,可通过控制台重装 openssh-server 恢复

如果你是要彻底最小化系统、替换成其他远程方式(如 dropbear),可以告诉我使用场景,我给你更合适的方案。

0 踩