在CentOS系统中,关闭Telnet服务可以通过以下步骤实现:
systemctl
命令停止Telnet服务:
sudo systemctl stop telnet.socket
禁用Telnet服务(防止系统重启后自动启动):
sudo systemctl disable telnet.socket
确认服务状态:
sudo systemctl status telnet.socket
如果服务已成功停止并禁用,输出中应该显示inactive (dead)
状态。
service
命令(适用于较旧的系统)停止Telnet服务:
sudo service xinetd stop
注意:在某些CentOS版本中,Telnet服务是通过xinetd
管理的,因此需要停止xinetd
来关闭Telnet。
禁用Telnet服务:
sudo chkconfig xinetd off
确认服务状态:
sudo service xinetd status
确保xinetd
服务已停止并且不会在启动时自动运行。
编辑/etc/xinetd.d/telnet
文件:
sudo vi /etc/xinetd.d/telnet
将disable = no
改为disable = yes
:
找到以下行:
disable = no
改为:
disable = yes
保存并退出编辑器。
重启xinetd
服务:
sudo systemctl restart xinetd
确认服务状态:
sudo systemctl status xinetd
通过以上步骤,你应该能够成功关闭CentOS系统中的Telnet服务。