Telnet [无法连接到远程主机:连接被拒绝]

Telnet [Unable to connect to remote host: Connection refused]

我试图在 Ubuntu 和 Guest OS (Kali) 之间创建一个 telnet 连接。但是 "Unable to connect to remote host: Connection refused" 问题出现在 Ubuntu 终端和 Guest OS (Kali) 终端。我按如下配置了Guest OS的ip设置,我可以从双方完美地发送ping数据包。

从收发的ping包来看,这两个系统之间的连接线路似乎没有问题。但是当我尝试输入

在Ubuntu中:

telnet ipAddressOfGuestOS

在访客中 OS:

telnet ipAddressOfUbuntu

终端returns"Unable to connect to remote host: Connection refused"错误。我该如何处理这个问题?

0.Configure Guest OS 通过 Virtualbox 如下。

VirtualBox Manager > Settings > Network 
Attached to: Bridged Adapter
Name : eth0
Advanced:
Promiscuous Mode: Allow All

1.Install telnet 在主 OS 终端中使用此命令:

sudo apt-get install xinetd telnetd 

2.Edit /etc/inetd.conf in main OS 使用你最喜欢的具有 root 权限的文件编辑器,添加这一行:

telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd

3.Edit /etc/xinetd.conf in main OS,使其内容如下所示:

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
}

4.Use 这个命令在 main OS:

中启动 telnet 服务器
sudo /etc/init.d/xinetd restart 

就是这样。顺便说一下,这个配置只会影响你使用的 main OS 而不是 Guest OS。也就是说,您可以创建仅从 Guest OS 的终端到 main OS 的 telnet 连接,而不是从 main OS 到 Guest OS。因为,telnet 服务器在 main OS。为了能够进行双向 telnet 通信,您应该在 Guest OS 的终端中重复上述步骤。

资源:http://ubuntuguide.net/install-and-enable-telnet-server-in-ubuntu-linux

  1. 检查 iptable 规则。

iptables -L

  1. 刷新 iptables

iptables -F

  1. 再次尝试远程登录

注意: 如果你flush iptables (when 运行: iptables -F) 它只会关闭你的ssh连接,所以你将无法连接到又是你的服务器

检查 telnet 服务是否 运行

psgrep xinetd 

首先我们需要使用此命令查看 ubuntu 系统日志

sudo gedit /var/log/syslog

如果你会看到这个错误 "execv( /usr/sbin/tcpd ) failed: No such file or directory" 那么 运行 这个命令

sudo apt-get install tcpd

它将解决您的问题(如果没有,那么您需要在 google 上搜索您的系统错误)