在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服務。