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

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.
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?

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

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
Check iptable rules.
iptables -L
Flush iptables
iptables -F
Try telnet again

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)

Check telnet service is running
psgrep xinetd

Related

I can't connect ssh between VMs

I just tried to create 3 ubuntu VMs on Virtualbox. then I tried to connect each machine to another machine using ssh but it failed.
"I noticed that the 3 VMs has the same IP, So I made static IP to each machine"
So kindly find the below steps:
$ sudo apt install ssh
$ sudo systemctl enable ssh
$ sudo systemctl start ssh
$ sudo ufw allow ssh
$ ssh username#ip
do a test of communication with these vms through ping.
If the communication is ok your problem must be related to the firewall.
You can disable your linux environment's firewall temporarily to test if this is really the problem.
If the problem is due to the firewall, you must create the release rule for a specific port. By default it is port 22.
Test suggestion: Stop SELinux and FirewallD or any other firewall in your distribution and retest

Setup ssh to connect 2 PC and use MPI

I am here because I've found different problems setting up SSH using this guide proposed in this other question.
First of all I've a computer (I want to use it as master) called: timmy#timmy-Lenovo-G50-80. My other computer is a Virtual Machine always with linux mint called: test#test-VirtualBox and I'd like to use it as a slave.
What I've done until now is:
install needed packets (both PC):
sudo apt-get install openssh-server openssh-client
Change inside the file /etc/ssh/sshd_config: (Only master)
the port of server from 22 to 2222
set PubkeyAuthentication yes (so no change)
remove comment at line: Banner /etc/issue.net
STOP
I am stuck when I've to execute this command:
ssh-copy-id username#remotehost
I imagine, reading what's written, that I've to execute something like:
ssh-copy-id timmy#timmy-Lenovo-G50-80
but:
from timmy#timmy-Lenovo-G50-80 everything goes OK, I can connect to myself (not what I actually want)
from test#test-VirtualBox it tells me ERROR: ssh: Could not resolve hostname timmy#timmy-Lenovo-G50-80: Name or service not known
Finally, what I've to do in order to connect these 2 PC?
You need to enable port forwarding into your VirtualBox'ed machine. Simply right click on the virtual machine, then go into Network. Then click on advance which will expand the Network window, and then on the button that appeared labeled Port forwarding.
A table will appear with several columns (Name, Protocol, Host IP, Host Port, ...). Simply add a new entry for protocol TCP, host port = X and guest port = 22 (see the list of well-known ports here https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports). The screenshot below is from my cloudera quickstart VM. Notice the outlined entry in the port forwarding rules, which is about setting up the SSH port in the guest OS.
Once you reboot the virtual machine, you can simply connect to it through
# ssh -p X localhost
the -p parameter tells to connect through the port X. Notice that if you want to use scp then you have to use the uppercase -P option rather than the lowercase -p.
# scp -P X localfile localhost:remote-dir/

How can I open some ports on Ubuntu?

I know a little about Linux. Today I created a VPN server on my Ubuntu installation according to Set up a simple IPsec/L2TP VPN server for Ubuntu, Arch Linux and Debian.
But when I finish the installation, I use my iPhone to connect the IPsec VPN, bur it shows the VPN Server has no response.
The GitHub document shows
Ports 1701, 500 and 4500 must be opened for the VPN to work!
So I have tried to open these ports on my Ubuntu server.
I use the iptables command to open these ports, but it failed. Maybe I don't known how to use this command correctly. How can I open these ports on my Ubuntu server?
And if these ports have been opened successfully, can it be proved by the Windows CMD window through telnet'ting the port?
Ubuntu these days comes with UFW - Uncomplicated Firewall. UFW is an easy-to-use method of handling iptables rules.
Try using this command to allow a port:
sudo ufw allow 1701
To test connectivity, you could try shutting down the VPN software (freeing up the ports) and using netcat to listen, like this:
nc -l 1701
Then use telnet from your Windows host and see what shows up on your Ubuntu terminal. This can be repeated for each port you'd like to test.
If you want to open it for a range and for a protocol
ufw allow 11200:11299/tcp
ufw allow 11200:11299/udp

SSH Permission denied for Mininet

I am new to SDN and was trying to learn Mininet. I have installed debian(64-bit) and Mininet on Virtual Box. When I try to connect Mininet Vm from Debian I have to run the following comamnd :
ssh -X mininet#10.0.2.15
It asks for mininet password, but after entering the default mininet password it shows an error
Permission denied please try again
Both my debian and Mininet VM have same IP address. Kindly guide how to eliminate the SSHerror. Also is it fine having same ip address for two different VM, is the SSH error a result of this ?
Thanks
In the VirtualBox settings under the tab Network click on Advanced then Port Forwarding and add a rule with name: ssh, protocol: tcp, host port: 3022 and guest port: 22. Then execute:
sudo ssh -p 3022 mininet#10.0.2.15

Available UDP port

I have a RedHat node behind central firewall and I would like to be able to check if the firewall guys have opened a port for me on which still nothing in listening. When I want to check that for TCP port I use telnet and I get:
When not opened:
[myname#78 ~]$ telnet myhost 4080
Trying myhostip...
telnet: connect to address myhostip: Connection refused
telnet: Unable to connect to remote host: Connection refused
[myname#78 ~]$
When opened:
[myname#78 ~]$ telnet myhost 4080
Trying myhostip...
Connected to myhost (myhostip).
Escape character is '^]'.
So how do I do that for an UDP port?
You can accomplish this using Netcat which you can install on RHEL with yum(1) using command yum install nc.
After you've installed Netcat, put it in listen mode on the receiving end ie. on the host you're trying to reach from outside world. You can do this with nc -l -u <your external I -address> 4080. This command will hang on your terminal and wait for any connections to port you specify on the command line.
Then connect from outside world, using Netcat again, but this time leave the -l out ie. use netcat -u <your external IP address> 4080. This command will also just sit there. Typing any input now should be visible on the receiving end Netcat. In case it is not, something blocks the traffic between two the two hosts.

Resources