linux telnet 之 telnet: Unable to connect to remote host: Connection refused

本文详细阐述了在Linux环境下使用telnet服务连接远程主机时遇到的问题及解决步骤,包括检查telnet服务状态、开启相关服务组件、重启服务等操作,最终成功实现远程连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天尝试telnet 利用 common.net  包中的 TelnetClient 来登陆linux并监控各种服务和运行脚本信息,在服务器中telnet 本机地址报错为
[root@dz_cj ~]# telnet 134.36.17.190
Trying 134.36.17.190...
telnet: connect to address 134.36.17.190: Connection refused

telnet: Unable to connect to remote host: Connection refused

1:首先查看telnet 服务是否开启:

chkconfig --list|grep telne

<span style="white-space:pre">	</span>[root@dz_cj ~]# chkconfig --list|grep telnet
        <span style="white-space:pre">	</span>ekrb5-telnet:   关闭
        <span style="white-space:pre">	</span>krb5-telnet:    关闭
        <span style="white-space:pre">	</span>telnet:         启用
         1:开启:   <span style="font-family: 'Courier New'; line-height: 1.5 !important;">chkconfig krb5</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">-</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">telnet on   无需开启 </span><span style="line-height: 25.2000007629395px; font-family: 'Courier New';">ekrb5-telnet 服务  -- 如果关闭的话用 </span><pre name="code" class="html" style="color: rgb(51, 51, 51); font-size: 14px; line-height: 25.2000007629395px;"><span style="font-family: 'Courier New'; line-height: 1.5 !important;"><span style="white-space:pre">		</span>chkconfig krb5</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">-</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">telnet off</span>

<span style="line-height: 25.2000007629395px; font-family: 'Courier New';"><span style="white-space:pre">	</span>2:激活:   <span style="font-family: 'Courier New'; line-height: 1.5 !important;">chkconfig krb5</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">-</span><span style="font-family: 'Courier New'; line-height: 1.5 !important;">telnet on</span></span>
<span style="line-height: 25.2000007629395px; font-family: 'Courier New';"><span style="font-family: 'Courier New'; line-height: 1.5 !important;">
</span></span>
<span style="line-height: 25.2000007629395px; font-family: 'Courier New';"><span style="font-family: 'Courier New'; line-height: 1.5 !important;"><span style="white-space:pre">	</span>开启后再次进行telnet  显示为:</span></span>
<span style="line-height: 25.2000007629395px; font-family: 'Courier New';"><span style="font-family: 'Courier New'; line-height: 1.5 !important;"><span style="white-space:pre">	</span></span></span><pre name="code" class="html">[root@dz_cj ~]# telnet 134.36.17.190
Trying 134.36.17.190...
Connected to dz_cj (134.36.17.190).
Escape character is '^]'.
Unencrypted connection refused. Goodbye.

Connection closed by foreign host.

   表示可以连接,但是这里 <span style="font-family: 'Courier New';">Unencrypted connection refused. Goodbye.</span>
<span style="font-family: 'Courier New';"></span><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">1)将文件/etc/xinetd.d/ekrb5-telnet里面的参数“disable”改成:</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">disable=yes</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">2)重启xinetd服务:</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">service xinetd restart</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">3)防止系统再次更改该参数值,执行:</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">chkconfig ekrb5-telnet off</p><p style="color: rgb(51, 51, 51); font-family: tahoma, 宋体; font-size: 14px; line-height: 22.3999996185303px; text-align: justify; background-color: rgb(250, 250, 252);">
</p>搞定!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值