1

I am doing a research on Telnet communication and I need to test its communication although it is not secure.

I have an Ubuntu machine 18.04 on my EC2 (I opened inbound port 23 for everyone in AWS).
I checked the status of the Telnet an it wasn't found:

root@ip:~# service telnet status
Unit telnet.service could not be found.  

I tried to install it with the following commands

apt update
apt --fix-broken install
apt-get install xinetd telnetd  

After that I created the file /etc/xinetd.d/telnet with the information I found here:

service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}

I tried to restart the service but it failed:

root@ip:~# service xinetd restart  
root@ip:~# service telnet restart  
Failed to restart telnet.service: Unit telnet.service not found.  

Any idea how to continue from here?

I checked the status of xinetd and it seems that the problem is that it uses the port 23 of telnet:

root@ip:~# service xinetd status
● xinetd.service - LSB: Starts or stops the xinetd daemon.
   Loaded: loaded (/etc/init.d/xinetd; generated)
   Active: active (running) since Thu 2021-02-18 16:25:05 UTC; 4min 7s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 16422 ExecStop=/etc/init.d/xinetd stop (code=exited, status=0/SUCCESS)
  Process: 16492 ExecReload=/etc/init.d/xinetd reload (code=exited, status=0/SUCCESS)
  Process: 16428 ExecStart=/etc/init.d/xinetd start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 1140)
   CGroup: /system.slice/xinetd.service
           └─16455 /usr/sbin/xinetd -pidfile /run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6

Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind retry attempt 8
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind failed (Address already in use (errno = 98)). service = telnet
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind retry attempt 9
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind failed (Address already in use (errno = 98)). service = telnet
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind retry attempt 10
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: bind failed (Address already in use (errno = 98)). service = telnet
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: Service telnet failed to start and is deactivated.
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16455]: Reconfigured: new=0 old=1 dropped=0 (services)
Feb 18 16:27:18 ip-172-31-17-160 xinetd[16492]:    ...done.
Feb 18 16:27:18 ip-172-31-17-160 systemd[1]: Reloaded LSB: Starts or stops the xinetd daemon..

I changed the telnet port from /etc/services to 2345 and restart the xinetd service but it still show me (xinet -d) the same errors.

2

Ubuntu 18.04

Install the packages

$ sudo apt-get update
$ sudo apt install xinetd telnetd telnet -y

Create a new file /etc/xinetd.d/telnet with following entries:

service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}

Then restart xinetd service

$ sudo /etc/init.d/xinetd restart

Time to test from server side:

$ telnet localhost

CentOS-7

Install the packages

$ sudo yum clean all && yum repolist
$ sudo yum install xinetd telnet-server telnet -y

Enable and start the services

$ sudo systemctl enable telnet.socket
$ sudo systemctl start telnet.socket

Allow telnet (TCP/23) through the firewall

$ sudo firewall-cmd --permanent --add-port=23/tcp
$ sudo firewall-cmd --reload

Test from server side

$ telnet localhost
7
  • Thanks, but it doesn't find telnet-server: Package 'telnet-server' has no installation candidate – E235 Feb 18 at 16:53
  • Did you refresh the apt packages by running apt-get update? – Bruce Malaudzi Feb 18 at 16:56
  • yes, it still doesn't find it. I am using Ubuntu 18.04. – E235 Feb 18 at 16:57
  • Let me double check. The command work for me on Debain Linux – Bruce Malaudzi Feb 18 at 17:02
  • My bad. The command I shared was tested on CentOS-7 – Bruce Malaudzi Feb 18 at 17:09
0

Remove xinetd, it's not needed anymore. I'd suggest removing telnetd also and then install only telnetd. By default uses openbsd-inetd nowadays.

But do you really need telnetd? It's insecure and should not be used, sshd is more than enough.

3
  • This is for research purposes, I first need to check the most unsecure and basic connection, so it's okay for me. – E235 Feb 18 at 16:59
  • I removed both xinetd and telnetd and re-installed telnetd but I still don't have a way to connect. I also didn't see any port 23 listening using netstat -ntlp. – E235 Feb 18 at 17:04
  • Was openbsd-inetd and tcpd installed as dependencies? In that case you can man inetd.conf, where you can find examples. Probably adding telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd in /etc/inetd.conf is enough, but have a look. – Krackout Feb 18 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.