今天尝试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
[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>搞定!