Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 安裝配置 Telnet 服務完整步驟(含 root 登入設定)

編輯:關於 Linux

安全警示: Telnet 明文傳輸帳號密碼,生產環境嚴禁使用,請改用 SSH。本文僅供內網隔離環境、教學實驗或老舊設備維護參考。

安裝流程(CentOS/RHEL 6/7 通用)

1. 安裝套件

yum install telnet-server -y
# CentOS 7 套件名相同

2. 配置 xinetd 啟用 Telnet

vim /etc/xinetd.d/telnet
# 修改 disable = no
service telnet
{
    flags           = REUSE
    socket_type     = stream
    wait            = no
    user            = root
    server          = /usr/sbin/in.telnetd
    log_on_failure  += USERID
    disable         = no
}

3. 允許 root 遠端登入(若需要)

# 檢查 /etc/securetty 是否包含 pts/0 等
grep pts /etc/securetty
# 若無,手動添加
echo -e "pts/0\npts/1\npts/2\npts/3" >> /etc/securetty

再次警示: 開啟 root Telnet 登入極度危險,僅限極受控環境臨時使用。

4. 啟動 xinetd 服務

# CentOS 6
service xinetd start
chkconfig xinetd on

# CentOS 7
systemctl start xinetd
systemctl enable xinetd

5. 驗證監聽埠

netstat -lnt | grep :23
# tcp  0  0 :::23  :::*  LISTEN

6. 建立測試帳號並連線測試

useradd telnetuser
passwd telnetuser

# 客戶端連線
telnet 
# 輸入帳號密碼測試

關鍵安全加固(若必須用 Telnet)

yum install openssh-server; systemctl start sshd 並禁用 Telnet
措施實施方式
限制來源 IPiptables -A INPUT -p tcp --dport 23 -s 192.168.1.0/24 -j ACCEPT; iptables -A INPUT -p tcp --dport 23 -j DROP
TCP Wrappers/etc/hosts.allow: in.telnetd: 192.168.1.0/255.255.255.0; /etc/hosts.deny: in.telnetd: ALL
改用 SSH
VPN/堡壘機將 Telnet 埠僅在 VPN 內網暴露

替代方案:SSH 才是正道

# 安裝 OpenSSH Server
yum install openssh-server -y
systemctl start sshd
systemctl enable sshd

# 禁用 Telnet
systemctl stop xinetd
systemctl disable xinetd
yum remove telnet-server

任何場景下,請優先部署 SSH,僅在極特殊舊設備無 SSH 支持時,才在嚴格網路隔離下啟用 Telnet。

Copyright © Windows教程網 All Rights Reserved