Telnet [Unable to connect to remote host: Connection refused]
Asked Answered
R

4

9

I was trying to create a telnet connection between Ubuntu and Guest OS (Kali). But the problem "Unable to connect to remote host: Connection refused" occurs in both Ubuntu terminal and Guest OS (Kali) Terminal. I configured Guest OS's ip settings as follows and I can send ping packets perfectly from both side.

enter image description here

According to ping packets sent and received, it seems there is no problem about connection line between these two system. But when I try to enter

In Ubuntu:

telnet ipAddressOfGuestOS

or

In Guest OS:

telnet ipAddressOfUbuntu

the terminal returns "Unable to connect to remote host: Connection refused" error. How can I handle this problem?

Recursion answered 21/12, 2015 at 5:44 Comment(3)
I'm guessing you don't have telnetd enabled. It is often disabled in distributions because it is considered insecure.Minneapolis
Following @Turn, ssh has been long preferred over the deprecated telnet.Rodeo
By default, telnet is not installed because of security concerns (namely, sending eveything - including passwords - in clear text)., BUT TELNET IS PERFECTLY OK FOR YOUR USE CASE: 1) Make sure the telnet daemon (telnetd) and client (telnet" are installed, 2) Enable telnetd service, 3) Open your iptables firewall for the telnet port, 4) Try to "telnet" LOCALLY, before you try "remote".Cesaria
R
10

0.Configure Guest OS via Virtualbox as follows.

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

1.Install telnet use this command in main OS terminal:

sudo apt-get install xinetd telnetd 

2.Edit /etc/inetd.conf in main OS using your favourite file editor with root permission,add this line:

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

3.Edit /etc/xinetd.conf in main OS,make its content look like following:

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 this command to start telnet server in main OS:

sudo /etc/init.d/xinetd restart 

That was all. By the way, this configuration will affect just main OS which you use instead of Guest OS. That is, you can create a telnet connection just from Guest OS's terminal to main OS, not from main OS to Guest OS. Because, telnet server is in main OS. To be able to do two way telnet communication, you should repeat the steps above in Guest OS's terminal.

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

Recursion answered 21/12, 2015 at 6:28 Comment(0)
D
3

Attention: if you flush iptables (when run: iptables -F) it can just close your ssh connection, so you will not be able to connect to your server again

  1. Check iptable rules.

iptables -L

  1. Flush iptables

iptables -F

  1. Try telnet again
Dedrick answered 21/12, 2015 at 18:0 Comment(2)
The warning about flushing IP tables should really be at the top.Kt
I just lost connection to the remote server doing iptables -FExcoriation
G
1

first we need to see ubuntu system log with this command

sudo gedit /var/log/syslog

and if you will see this error "execv( /usr/sbin/tcpd ) failed: No such file or directory" then run this command

sudo apt-get install tcpd

it will solve your problem (if not then you need to search your system error on google)

Gin answered 21/5, 2020 at 15:20 Comment(1)
Was banging my head on this for hours, installing tcpd is all it took to fix. Never would've figured this out!Wore
A
0

Check telnet service is running

psgrep xinetd 
Abraham answered 2/2, 2018 at 11:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.