CentOS 7 下 Telnet 远程 root 登录

CentOS 7 下 Telnet 远程 root 登录

Telnet 服务 && 依赖包安装

下载安装包
  • 下载 telnet-server
https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/telnet-server-0.17-65.el7_8.x86_64.rpm
  • 下载 xinetd
https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/xinetd-2.3.15-14.el7.x86_64.rpm
安装安装包
  • 安装 telnet-server
[root@localhost ~]# rpm -ivh telnet-server-0.17-65.el7_8.x86_64.rpm 
warning: telnet-server-0.17-65.el7_8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:telnet-server-1:0.17-65.el7_8    ################################# [100%]
  • 安装 xinetd
[root@localhost ~]# rpm -ivh xinetd-2.3.15-14.el7.x86_64.rpm 
warning: xinetd-2.3.15-14.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:xinetd-2:2.3.15-14.el7           ################################# [100%]

配置 && 启动服务

关闭防火墙
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl stop firewalld
关闭 SELinux
# 临时关闭
[root@localhost ~]# setenforce 0
修改安全文件
# 增加配置
[root@localhost ~]# cat <<  EOF >> /etc/securetty
pts/0
pts/1
EOF
修改 pam 模块 telnet 权限
# 修改前
[root@localhost ~]# grep 'pam_securetty.so' /etc/pam.d/remote 
auth       required     pam_securetty.so

# 修改后 -- 注释掉
[root@localhost ~]# grep 'pam_securetty.so' /etc/pam.d/remote 
# auth       required     pam_securetty.so
配置 telnet-server 参数
# 新建文件
[root@localhost ~]# cat << EOF > /etc/xinetd.d/telnet
service telnet
{
    flags = REUSE
    socket_type = stream
    wait = no
    user = root
    server = /usr/sbin/in.telnetd
    log_on_failure += USERID
    disable = no
}
EOF
启动 telnet-server
[root@localhost ~]# systemctl start telnet.socket
启动 xinetd
[root@localhost ~]# systemctl start xinetd

验证 root 通过 telnet 远程登陆

验证 telnet 服务状态
[root@localhost ~]# systemctl status telnet.socket
● telnet.socket - Telnet Server Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled)
   Active: active (listening) since Wed 2022-11-02 19:04:00 CST; 26s ago
     Docs: man:telnetd(8)
   Listen: [::]:23 (Stream)
 Accepted: 0; Connected: 0
验证 xinetd 服务状态
[root@localhost ~]# systemctl status xinetd -l
● xinetd.service - Xinetd A Powerful Replacement For Inetd
   Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2022-11-02 19:04:06 CST; 1min 1s ago
  Process: 1739 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid $EXTRAOPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1740 (xinetd)
   CGroup: /system.slice/xinetd.service
           └─1740 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
验证 telnet 端口
[root@localhost ~]# ss -ntlp | grep 23
LISTEN     0      128       [::]:23        [::]:*       users:(("systemd",pid=1,fd=26))
验证 root 通过 telnet 登录
[C:\~]$ telnet 192.168.68.129


Connecting to 192.168.68.129:23...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Kernel 3.10.0-1127.el7.x86_64 on an x86_64
localhost login: root
Password: 
Last login: Wed Nov  2 19:02:11 from 192.168.68.1

参考

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值