How to Install and Use Telnet on Ubuntu 20.04 LTS

Telnet is a terminal emulation program for TCP/IP networks that allows you to access another computer on the Internet or local area network by logging in to the remote system. Telnet is a client-server protocol used to establish a connection to Transmission Control Protocol port number 23. You can also check open ports on a remote system using Telnet.

In this tutorial, we will learn how to install and use Telnet Server and Client on Ubuntu 20.04 LTS server.

WARNING: Telnet is an unencrypted and therefore insecure protocol. This tutorial exists for educational reasons only and not as a recommendation to use Telnet Server on your system. This guide shows you how to install and use the Telnet client and server in case you are interested in learning more about this ancient server management protocol or in case you want to use the Telnet client to test your mail server. We do NOT recommend using Telnet (Server) on servers today, especially not when using it over the internet. To manage your server over the network, use SSH instead of Telnet. Using a Telnet client is something different, a telnet client is a useful tool to e.g. test your mail or web server as shown below.

Requirements

  • A server running Ubuntu 20.04 server.
  • A non-root user with sudo privileges.
  • A static IP address 192.168.0.100 configure on your server.

Install Telnet Server

By default, Telnet server package is available in the Ubuntu 20.04 default repository. You can install it by just running the following command:

sudo apt install telnetd -y

Once the installation is completed, you can check the status of Telnet service using the following command:

sudo systemctl status inetd

Output:

? inetd.service - Internet superserver
   Loaded: loaded (/lib/systemd/system/inetd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-04-29 10:24:05 UTC; 38s ago
     Docs: man:inetd(8)
 Main PID: 2883 (inetd)
    Tasks: 1 (limit: 1114)
   CGroup: /system.slice/inetd.service
           ??2883 /usr/sbin/inetd

Apr 29 10:24:05 ubuntu2004 systemd[1]: Starting Internet superserver...
Apr 29 10:24:05 ubuntu2004 systemd[1]: Started Internet superserver.

Test Telnet Connection from Remote System

Telnet server is now installed and listening on port 23. It's time to connect Telnet server from the remote system.

Now, log in to another Ubuntu system and run the following command:

telnet 192.168.0.100

You will be asked to enter your username and password. After successful authentication, you should see the following output:

Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.
Ubuntu 20.04 LTS
ubuntu2004 login: hitesh
Password: 
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-72-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Thu 29 Apr 2021 09:16:14 AM UTC

  System load:            0.83
  Usage of /:             14.7% of 39.12GB
  Memory usage:           30%
  Swap usage:             0%
  Processes:              163
  Users logged in:        0
  IPv4 address for ens33: 192.168.0.100
  IPv6 address for ens33: 2003:e1:bf4b:8b00:20c:29ff:fef5:ee3c

 * Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!

     https://microk8s.io/

8 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable


Last login: Wed Apr 28 08:50:37 2021 from 192.168.0.20 

You can now run any command on Telnet server using Telnet.

Use telnet to Test Open Ports

You can also use Telnet to test open ports on a remote system.

For example, to test port 80 on the remote system (IP 192.168.0.100) run the following command:

telnet 192.168.0.100 80

If port 80 is open, you should see the following output:

Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.

If port 80 is blocked or the Telnet service is not running. You should see the following output:

Trying 192.168.0.100...
telnet: Unable to connect to remote host: Connection refused
Share this page:

Suggested articles

4 Comment(s)

Add comment

Comments

By: jogi at: 2020-04-08 13:43:46

i have ubintu 18.4 and i want to control my windows pc from ubunto , what port numbe i should use o

By: Peter Roy at: 2020-07-08 15:05:58

The port you use is up to you. Choose wisely and > 1024. Every server by defenition has a port, http will be 80 and https will be 443. If you use vnc or rdp the port will be by defenition diferent. Either use the default fort each service or choose wisely.

By: Sifa at: 2020-05-19 06:10:21

So far the most comprehensive tutorial i have seen about telnet on the internets. Thank you

By: Richard at: 2021-03-31 18:02:41

It might be helpful to mention how to end a connection when testing open ports. I tried - exit, logout, end - and a few others. I guess it's supposed to be - close.