转载!非常有用:Ubuntu中telnet 127.0.0.1时Unable to connect to remote host: Connection refused(亲测解决)_ubuntu虚拟机telnet: unable to connect to remote host:-CSDN博客
安装Telnet客户端和服务器,安装 xinetd
$ sudo apt-get install telnet
$ sudo apt-get install telnetd
$ sudo apt-get install xinetd
2)修改配置文件
$ sudo vi /etc/inetd.conf添加:
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
$ sudo vi /etc/inetd.conf修改为:
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
$ sudo vi /etc/xinetd.d/telnet添加:
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
使用netstat -tnl检验是否安装成功:netstat -tnl
进程在监听本地的23端口,说明本地的telnet服务启动。
其中遇到问题:
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
应该是没有成功安装telnet服务,可能是因为以下问题
1.$ sudo vim /etc/inetd.conf添加:
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
不用前面加#
2.sudo vi /etc/xinetd.d/telnet添加这一步中,telnet文件本来没有,是创建这个文件。
3.如果依照以上执行还是没有监听23端口,那么进行虚拟机重启,再次使用netstat -tnl命令检验是否安装成功。这时一般均成功。