温馨提示×

Linux中Telnet服务的启动与停止

小樊
36
2025-12-08 01:20:21
栏目: 智能运维

在Linux系统中,Telnet服务允许用户通过Telnet客户端远程登录到服务器并执行命令

  1. 启动Telnet服务:

对于基于Systemd的系统(如Ubuntu 16.04及更高版本、CentOS 7及更高版本):

sudo systemctl start telnet.socket

对于基于SysVinit的系统(如较旧的Ubuntu和CentOS版本):

sudo service xinetd start
  1. 停止Telnet服务:

对于基于Systemd的系统:

sudo systemctl stop telnet.socket

对于基于SysVinit的系统:

sudo service xinetd stop
  1. 设置Telnet服务开机自启:

对于基于Systemd的系统:

sudo systemctl enable telnet.socket

对于基于SysVinit的系统:

sudo chkconfig xinetd on

注意:Telnet协议不安全,因为它在网络上以明文形式传输数据。建议使用更安全的替代方案,如SSH(Secure Shell)。要安装和使用SSH,请参阅以下命令:

  1. 安装SSH服务:

对于基于Systemd的系统:

sudo apt-get install openssh-server   # Ubuntu/Debian
sudo yum install openssh-server       # CentOS/RHEL

对于基于SysVinit的系统:

sudo apt-get install openssh-server   # Ubuntu/Debian
sudo yum install openssh-server       # CentOS/RHEL
  1. 启动SSH服务:

对于基于Systemd的系统:

sudo systemctl start ssh

对于基于SysVinit的系统:

sudo service sshd start
  1. 设置SSH服务开机自启:

对于基于Systemd的系统:

sudo systemctl enable ssh

对于基于SysVinit的系统:

sudo chkconfig sshd on

0