Jan 19, 2024 4 min read

How to Install SSH on Ubuntu 22.04

Install ssh on ubuntu 22.04 with our step-by-step tutorial. It is a cryptographic network protocol that allows secure remote access.

Install SSH on Ubuntu 22.04
Install SSH on Ubuntu 22.04
Table of Contents


Before we discuss how to install ssh on ubuntu 22.04, let's first understand-What is SSH?

SSH (Secure Shell) is a cryptographic network protocol that allows secure remote access and secure file transfer between two computers. It offers a safe method of connecting to distant servers or devices, controlling them from a distance, and sending files back and forth.

This tutorial will walk you through the installation of SSH on Ubuntu 22.04, discuss its advantages, frequently asked questions (FAQs), and conclude.


  1. Secure Remote Access: SSH provides secure remote access to Ubuntu 22.04 systems, allowing you to connect to them remotely and perform administrative tasks.
  2. Encryption and Authentication: SSH uses encryption and strong authentication methods, making it secure for transmitting data over an untrusted network.
  3. Portability: SSH is widely supported on various platforms, including Ubuntu 22.04, Linux, macOS, and Windows, making it easy to connect to remote systems regardless of the operating system.
  4. Secure File Transfer: SSH enables secure file transfer between systems, allowing you to securely upload or download files to and from remote servers.
  5. Tunneling and Port Forwarding: SSH supports tunneling and port forwarding, allowing you to securely access services on remote systems through encrypted tunnels.


  • An Ubuntu 22.04 system with root privileges

Steps to Install SSH on Ubuntu 22.04

Step 1. Update the system

Before you start, make sure your system is up to date. Open a terminal window and type the following commands into it:

sudo apt update
sudo apt upgrade

Step 2: Install the OpenSSH Server

It is necessary to install the OpenSSH server before you can enable SSH on your Ubuntu computer. In the terminal window, type the following command:

sudo apt install openssh-server

Step 3: Configure Firewall Rules for SSH

By default, Ubuntu handles firewall rules using the Uncomplicated Firewall (UFW). First, perform the following steps to see UFW's current state:

sudo ufw status

Use the following command to enable UFW if it's not yet working:

sudo ufw enable

Next, create a new firewall rule to permit incoming SSH connections:

sudo ufw allow ssh

Step 4: Change the Default SSH Port

The default SSH port will be changed from 22 to 33556 in this example. If you would rather, change the port number you chose, just be sure it isn't being used by another service.

The original SSH configuration file should first be backed up:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

Next, open the SSH configuration file in a text editor like nano:

sudo nano /etc/ssh/sshd_config

Change the port number to the appropriate one by locating the line that begins with #Port 22. Remove the # at the start of a line to uncomment it. As an illustration:

Port 33556

Save the document, then close the text editor.

Step 5: Set Up Firewall Rules for the Personalized SSH Port

Update the firewall rules to allow inbound connections on the assigned SSH port. Delete the preceding SSH rule first:

sudo ufw delete allow ssh

Then, make a new rule for the distinct SSH port:

sudo ufw allow 33556/tcp

Step 6: Restart the SSH Service

Restarting the SSH service is necessary to apply the changes:

sudo systemctl restart ssh

Step 7: Verify the Configuration

Execute the following command within the terminal window to verify that SSH is enabled and that the firewall rules and new SSH port have been configured appropriately:

sudo systemctl status ssh

If the configuration was successful, information about the SSH service using the new port number should be accessible.

Step 8: Join up to the Specific SSH Port

Make sure you specify the new custom port when establishing an SSH connection to your system. Use the following command. For instance, if your system's IP address is and the SSH port has been modified to 33556:

ssh -p 33556 [email protected]

On your Ubuntu 22.04 system, you have successfully enabled SSH, set up the required firewall rules, and modified the default SSH port. In the future, when you connect to your system using SSH, don't forget to use the custom port.

FAQs to Install SSH on Ubuntu 22.04

Is SSH already installed on Ubuntu 22.04?

SSH is not installed by default on Ubuntu 22.04. You need to install the SSH server package to enable SSH access.

How can I install SSH on Ubuntu 22.04?

To install SSH on Ubuntu 22.04, open a terminal and run the command: sudo apt install openssh-server.

How do I enable SSH access on Ubuntu 22.04?

Once the SSH server package is installed, SSH access is automatically enabled. You can connect to the Ubuntu system using an SSH client.

How do I find the hostname or IP address of an Ubuntu 22.04 system?

You can find the hostname by running the hostname command in a terminal. To find the IP address, use the ip address show or ifconfig command.

How do I connect to an Ubuntu 22.04 system using SSH?

To connect to an Ubuntu 22.04 system using SSH, open an SSH client (e.g., Terminal on Linux/macOS, PuTTY on Windows) and use the following command: ssh username@hostname.

How do I find the hostname or IP address of an Ubuntu 22.04 system?

You can find the hostname by running the hostname command in a terminal. To find the IP address, use the ip address show or ifconfig command.

How do I check if the SSH service is running on Ubuntu 22.04?

You can check the status of the SSH service on Ubuntu 22.04 by running the command: systemctl status ssh.


By following the installation steps mentioned in the tutorial and configuring SSH appropriately, you can facilitate secure communication and file transfer between Ubuntu 22.04 systems and other devices.

If you have any queries, you can ask them in the comments section, and we would be happy to answer them...

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.