温馨提示×

ubuntu如何开启telnet服务

小樊
148
2025-02-16 07:11:29
栏目: 智能运维
Ubuntu服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Ubuntu系统中开启Telnet服务,可以按照以下步骤进行:

方法一:使用systemctl命令

  1. 更新系统包列表

    sudo apt update
    
  2. 安装Telnet服务器

    sudo apt install telnetd
    
  3. 启用并启动Telnet服务

    sudo systemctl enable telnet.socket
    sudo systemctl start telnet.socket
    
  4. 检查Telnet服务状态

    sudo systemctl status telnet.socket
    
  5. 配置防火墙(如果需要): 如果你的系统启用了防火墙(如UFW),你需要允许Telnet流量通过。可以使用以下命令:

    sudo ufw allow 23/tcp
    

方法二:使用inetdxinetd

  1. 安装inetdxinetd

    sudo apt install inetd
    

    或者

    sudo apt install xinetd
    
  2. 编辑/etc/inetd.conf/etc/xinetd.d/telnet文件

    • 对于inetd
      sudo nano /etc/inetd.conf
      
      找到并取消注释以下行:
      telnet    stream  tcp     nowait  root    /usr/sbin/in.telnetd
      
    • 对于xinetd
      sudo nano /etc/xinetd.d/telnet
      
      添加或修改以下内容:
      service telnet
      {
          disable = no
          socket_type = stream
          protocol = tcp
          wait = no
          user = root
          server = /usr/sbin/in.telnetd
          log_on_failure += USERID
      }
      
  3. 重启inetdxinetd服务

    • 对于inetd
      sudo systemctl restart inetd
      
    • 对于xinetd
      sudo systemctl restart xinetd
      
  4. 检查服务状态

    sudo systemctl status inetd
    

    或者

    sudo systemctl status xinetd
    

注意事项

  • Telnet协议不安全,因为它传输的数据是明文的。在生产环境中,建议使用更安全的SSH协议。
  • 确保你的网络配置允许外部访问Telnet端口(默认是23)。

通过以上步骤,你应该能够在Ubuntu系统上成功开启Telnet服务。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:centos怎么开启telnet服务

0