Categories: TutorialsUbuntu

How to Set Up SSH on Ubuntu 22.04?

SSH (Secure Socket Shell) is a client-server technology that allows system administrators to access an unsecured network in a secure way. SSH is a network protocol like HTTP that is used on top of the TCP/IP layer and is part of the “Application Layer”. The SSH consists of a “transport layer”, a “connection layer”, and a “user authentication layer”. On Ubuntu, the OpenSSH Client runs on the TCP Port 22.

This article explains the integration of SSH with Ubuntu 22.04.

How to Set Up SSH on Ubuntu 22.04?

To set up SSH on Ubuntu, follow the procedure below with each step explaining the commands in a simple way:

Step
Sponsored
1: Update and Upgrade Ubuntu System

Before installing SSH, make sure to update the repository first and then upgrade the packages. To update and upgrade use the command:

sudo apt update

To upgrade use the command:

sudo apt upgrade

Step 2: Installing SSH

To install SSH, use the command “openssh-server” with the apt install in the terminal.

sudo apt install openssh-server -y

It will take some time to install the necessary packages, wait for it:

Step 3: Checking the Status of the Server

Once the installation of the SSH Server is completed, confirm by checking the status of the server. To check the status, use the following command:

sudo systemctl status ssh

Step 4: Allowing Connection

As the SSH Server is running, now we need to allow the connection on the SSH Port. Use the command below:

sudo ufw allow ssh

This will allow the connection:

Step 5: Save the UFW Rules

UFW or “Uncomplicated FireWall” is a user-friendly tool used for managing “ip-tables” and “firewall rules”. Enable and reload the “ufw” to save changes in “ufw” using the command:

sudo ufw enable && sudo ufw reload

This will configure the Firewall:

Step 6: Connect the Client to the Host

To connect another Linux System to the Host System using SSH ensure that “openssh-server” is installed and you use the correct IP Address and Hostname with the command

ssh strong>hostnamestrong>>@strong>ipstrong> address>

In our case, our host has the IP of “192.168.184.30” and the hostname is “tahakhan”. To check the IP address of your Ubuntu system, use the command:

ip a

This will display the IP Address of the Ubuntu system

Sponsored

Now, in the client or any other system, use the command below to connect to the host server.

ssh tahakhan@192.168.184.130

In our case, we have a Client System named “ubuntu1” and its IP is “192.168.184.131”:

To connect the client “ubuntu1” with server “tahakhan”, our command will be:

ssh tahakhan@192.168.184.130

It will ask for confirmation to continue the connection. Enter “yes”:

Now it will ask for the server host(tahakhan) password for authentication:

Enter the host system password. If the password is verified, you will see the Login status and you will now have access to the server system.

Use the “ls” command to list the host system files:

Using this procedure, you can connect and access the host system.

Step 7: Logout of the Server

To logout the client (ubuntu1) from the server (tahakhan), use the command:

exit

This will log you out from the Server and Exit it. You will be back on your client system again:

Step 8: Checking Login History (Optional)

In the hosting system, you can also verify and check the recent login from clients using the command:

grep “sshd” /var/log/auth.log

Check the recent history by scrolling down to the last info. Here you can see the recent connection by the client having an IP Address of “192.168.184.131”. This IP Address was of the client “ubuntu1”.

Conclusion

To Set Up SSH on Ubuntu 22.04, first, use the “openssh-server”, update the rules, and configure the firewall to allow “ssh” connections over a secure connection of the host with clients. SSH is used for secure connection to host servers and we can remotely access files and devices on the host system. This article explained how we can use the “openssh-server”, update the rules to allow “ssh” connections, and then configure the firewall to allow a secure connection of the host with clients.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago