Telnet is a versatile network protocol that enables users to interact with remote systems, such as Linux VPS servers. It is less secure than protocols like SSH, but Telnet can still be useful for specific tasks, such as testing network services or checking open ports using Telnet. This guide will provide you with a step-by-step approach to how to use telnet on linux, with easy-to-follow examples.
What is Telnet?
Telnet stands for TerminaL Network. It enables users to connect to remote servers over a network. Once connected, you can run commands on a server as you are directly working with it. While SSH (Secure Shell) is the preferred choice for most remote connections due to its good security, Telnet is still valuable for many tasks like:
- Testing Connectivity: Quickly check if a server or port is reachable using telnet.
- Troubleshooting Services: Diagnose issues with network services using telnet.
How to Install Telnet on Linux VPS Servers
Telnet may not be pre-installed on your Linux VPS server. To check if it is available, open your terminal and type:
telnet
If you see a message like bash: telnet: command not found, it means Telnet is not installed. Depending on your Linux distribution, you can easily install Telnet using the package manager.
Installing Telnet On Ubuntu/Debian-based Systems
Run the following commands:
sudo apt install telnet
Install Telnet On CentOS/RHEL-based Systems
Use these commands:
sudo yum install telnet
After you have finished the installation, you can use Telnet.
Basic Syntax of Telnet Command
To connect to a server using Telnet, use the following telnet syntax:
telnet [hostname or IP address] [port]
- Hostname/IP Address: The address of the server to connect using telnet.
- Port: The port number for the service you are accessing by telnet (default is 23).
Below are some telnet examples which can be used for running the commands
Example 1: Connecting to a Remote VPS Server
To connect to a VPS server using telnet on IP address 192.168.1.5, enter:
telnet 192.168.1.5
If successful, it’ll ask for your login details.
Example 2: Checking Open Ports on a VPS Server Using Telnet
Telnet can check if a specific port on a remote VPS is open. For instance, to use telnet to test port, if port 80 (commonly used for HTTP) is open on a web server, use:
telnet example.com 80
If the connection succeeds, the port is open. If it fails, the port may be closed, or the server is unreachable.
Example 3: Sending HTTP Requests via Telnet
You can use Telnet to send HTTP requests to a web server running on your VPS. Connect to the server’s HTTP port (port 80) with:
telnet example.com 80
After connecting, type the following to make an HTTP request:
GET / HTTP/1.1
Host: example.com
After pressing Enter twice, the server should respond with the HTML content of the webpage.
Example 4: Testing Mail Servers on VPS
Telnet is helpful for testing email servers by connecting to their specific ports. To test an SMTP server using Telnet (used for sending emails) on port 25, use:
telnet mail.example.com 25
Once connected, you can manually send commands like:
HELO
MAIL FROM:
RCPT TO:
These commands help test the server’s functionality.
Exiting a Telnet Session
To Exit a Telnet session, follow these steps:
- Press Ctrl + ] to enter the Telnet prompt.
- At the Telnet prompt, type:
quit
This action ends the session and brings you back to the terminal.
Troubleshooting Telnet on Linux VPS Servers
Here are some common issues when using Telnet and their solutions:
Connection Refused
It means the server is not allowing connections on the specific port you are trying to access. Make sure that the service is running on the server and that the port is open.
Unable to Connect to Remote Host
It could be network problems, an incorrect IP or hostname, or a firewall preventing the connection. Verify that the server is reachable and that there are no firewall rules preventing access.
Command Not Found
If the Telnet command isn’t recognized, it means Telnet is not installed. Refer to the installation section to resolve this issue.
Telnet Security Considerations
Plain Text data sent through telnet can mean that third parties have access to your usernames, passwords, and any other sensitive information you transmit. It is better to use SSH for a secure connection to your VPS server.
Conclusion
Telnet is a resourceful tool for network diagnostics and troubleshooting on Linux systems. Telnet can be handy in Linux in determining whether an open port is being used or if the network service associated with it is available. If you need to connect to remote servers (or even the hosts right on your PC) and run some commands as if you were physically present, that’s where the telnet command in Linux comes in. Although Telnet lacks encryption compared to alternatives like SSH, it’s still valuable in controlled environments. We’ve covered how to install Telnet on Linux, including Ubuntu and Debian, along with sample Telnet syntax and commands.
If you’re managing a VPS and need reliable performance, explore Voxfor’s Lifetime VPS for a robust, secure solution that’s built to last.
About Author
Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.