Linux/Unix SSH, Ping, FTP, Telnet Communication Commands

โšก Smart Summary

Linux communication commands such as SSH, Ping, FTP, and Telnet let you connect to remote systems, test network reachability, transfer files, and administer servers directly from the terminal on any Linux or Unix machine.

  • ๐Ÿ” SSH: Secure Shell connects to remote machines over an encrypted channel on TCP port 22, replacing insecure Telnet for server administration.
  • ๐Ÿ“ก Ping: The ping command sends ICMP packets to confirm a host is reachable and to measure connection health.
  • ๐Ÿ“ FTP: File Transfer Protocol uploads and downloads files between local and remote computers using commands such as put and get.
  • ๐Ÿ’ป Telnet: Telnet opens a remote terminal session on port 23 but sends data, including passwords, in plain text.
  • ๐Ÿ”’ Security: Prefer SSH and SFTP over Telnet and plain FTP because they encrypt credentials and data in transit.
  • ๐Ÿค– AI assistance: AI assistants and GitHub Copilot can generate connection commands and help diagnose network errors.

Linux and Unix communication commands SSH, Ping, FTP, and Telnet

While working on a Linux operating system, you may need to communicate with other devices. For this, there are some basic utilities that you can make use of. These utilities help you communicate with networks, other Linux systems, and remote users. The illustration below shows how these tools link your machine to networks and remote hosts.

Linux communication utilities linking a computer to networks and remote systems

So, let us learn them one by one: SSH, Ping, FTP, and Telnet.

SSH

SSH, which stands for Secure Shell, is used to connect to a remote computer securely. Compared to Telnet, SSH is secure because the client/server connection is authenticated using a digital certificate and passwords are encrypted. Hence, it is widely used by system administrators to control remote Linux servers.

The syntax to log into a remote Linux machine using SSH is:

ssh username@ip-address or hostname

The screenshot below shows a terminal connecting to a remote machine with the ssh command.

Logging into a remote Linux machine using the ssh command

Once you are logged in, you can execute any commands that you would run in your own terminal. For example, use the ls command to list the files in the current directory:

ls

The output of the ls command appears as shown below.

Output of the ls command listing directory contents over an SSH session

Similarly, run the pwd command to print the current working directory:

pwd

The pwd command returns the path of the working directory, as shown below.

Output of the pwd command showing the working directory over an SSH session

Ping

The ping utility is commonly used to check whether your connection to a server is healthy or not. This command is also used for:

  • Analyzing network and host connections
  • Tracking network performance and managing it
  • Testing hardware and software issues

Command syntax:

ping hostname or IP-address

For example, ping a device by its IP address:

ping 172.16.170.1

The ping command sends packets to the IP address and reports the replies, as shown below.

Output of the ping command sending packets to an IP address

You can also ping a host by its domain name:

ping google.com

The output below shows ping reaching a host through its hostname.

Output of the ping command reaching a host by its domain name

Here, a system sends 64-byte data packets to the IP address (172.16.170.1) or the hostname (www.google.com). If even one of the data packets does not return or is lost, it suggests an error in the connection. Internet connectivity is usually checked using this method. You may press Ctrl + c to exit the ping loop.

FTP

FTP is the File Transfer Protocol. It is the most preferred protocol for transferring data among computers. The illustration below represents an FTP file transfer between a local and a remote computer.

FTP file transfer between a local computer and a remote host

You can use FTP to:

  • Log in and establish a connection with a remote host
  • Upload and download files
  • Navigate through directories
  • Browse the contents of directories

The syntax to establish an FTP connection to a remote host is:

ftp hostname or IP-address

Once you enter this command, it asks you for authentication using a username and password, as shown below.

Authenticating to a remote host with a username and password over FTP

Once a connection is established and you are logged in, you can use the following commands to perform different actions.

Command Function
dir Display files in the current directory of a remote computer
cd “dirname” Change directory to “dirname” on a remote computer
put file Upload ‘file’ from local to remote computer
get file Download ‘file’ from remote to local computer
quit Log out

The screenshot below shows some of these important FTP commands being run in a session.

Running FTP commands such as dir, get, and put in a terminal session

Telnet

Telnet helps you to:

  • Connect to a remote Linux computer
  • Run programs remotely and conduct administration

This utility is similar to the Remote Desktop feature found on Windows machines. The illustration below shows a Telnet connection to a remote Linux computer.

Telnet session connecting to a remote Linux computer

The syntax for this utility is:

telnet hostname or IP-address

For example, connect to your own computer (localhost):

telnet localhost

For demonstration purposes, we will connect to your computer (localhost). The utility asks for your username and password, as shown below.

Connecting to localhost with the telnet command and being prompted for credentials

Once authenticated, you can execute commands just as you have done so far using the terminal. The only difference is that, if you are connected to a remote host, the commands are executed on the remote machine and not on your local machine. You may exit the Telnet connection by entering the command ‘logout’.

Why SSH Replaced Telnet

Telnet, one of the oldest remote-access tools, sends everything you type โ€” including your username and password โ€” across the network as plain text on port 23. Anyone capturing that traffic can read the credentials, which makes Telnet unsafe on the public internet. SSH was designed to fix exactly this weakness.

SSH improves on Telnet in several important ways:

  • Encryption: SSH encrypts the entire session over port 22, so passwords and data cannot be read in transit.
  • Authentication: SSH verifies the server with a digital key and supports key-based logins that are stronger than passwords.
  • Integrity: SSH detects if the data stream is tampered with during transfer.

Because of these protections, system administrators now use SSH to manage remote Linux servers, and Telnet survives mainly for quick testing or on trusted internal networks.

SSH, Ping, FTP, and Telnet Compared

Each of these utilities solves a different communication problem, from testing a link to moving files and running remote sessions. The table below summarizes how they compare so you can pick the right tool.

Utility Purpose Protocol Default Port Encrypted
SSH Secure remote login and administration TCP (SSH) 22 Yes
Ping Test whether a host is reachable and measure latency ICMP None (portless) Not applicable
FTP Transfer files between hosts TCP (FTP) 21 (20 for data) No (plain FTP)
Telnet Remote terminal access TCP (Telnet) 23 No

For anything exposed to the internet, choose the encrypted options: SSH for remote sessions and SFTP or SCP (both of which run over SSH) for file transfers.

FAQs

FTP transfers files and passwords as plain text, so anyone monitoring the network can read them. SFTP does the same job inside an encrypted SSH connection on port 22, protecting your credentials and data. For any transfer over the internet, SFTP is the safer choice.

SCP (Secure Copy) copies files between hosts over an encrypted SSH channel, so it is secure like SFTP. It is faster but more limited, as it only copies files and cannot list, rename, or delete them. Modern guides recommend SFTP or rsync over SCP.

Type exit or logout and press Enter to close an SSH or Telnet session and return to your local terminal. If a session hangs, SSH also accepts the escape sequence: press Enter, then type a tilde followed by a period (~.) to force the connection closed.

No. Ping uses ICMP, a network-layer protocol that works without port numbers. It sends an ICMP echo request and waits for an echo reply. Because it does not rely on TCP or UDP, firewalls sometimes block ICMP even when other services remain reachable.

By default, Linux ping runs until you stop it with Ctrl + c. Add the -c option with a number to send a fixed count, for example ping -c 4 google.com sends four packets and then stops automatically, which is handy inside scripts and health checks.

“Connection refused” usually means the SSH service is not running on the remote host, or a firewall is blocking port 22. Confirm that sshd is installed and started, check the host address and port, and make sure network rules allow the connection before retrying.

Machine-learning tools can scan ping results, SSH logs, and packet captures to spot latency spikes, failed logins, and anomalies that a human might miss. AI assistants also explain cryptic error messages and suggest the next diagnostic command, speeding up network troubleshooting.

Yes. GitHub Copilot can draft shell scripts that automate SSH logins, batch FTP transfers, and scheduled ping checks. It suggests command flags and loops as you type, though you should always review generated connection and credential handling before running it.

Summarize this post with: