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 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

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

Predict, compare, and reduce costs with our S3 cost calculator

Previously I have written about how useful public cloud storage can be when starting a…

21 hours ago

One Thread to Poll Them All: How a Single Pipe Made WaterDrop 50% Faster

This is Part 2 of the "Karafka to Async Journey" series. Part 1 covered WaterDrop's…

1 day ago

A year of documentation-driven development

For many software teams, documentation is written after features are built and design decisions have…

2 days ago

Announcing FIPS 140-3 for Ubuntu Core22

With the release of the FIPS 140-3 certified cryptographic modules for Ubuntu 22.04 LTS, Canonical…

3 days ago

The foundations of software: open source libraries and their maintainers

Open source libraries are repositories of code that developers can use and, depending on the…

6 days ago

From inspiration to impact: design students from Regent’s University London explore open design for their dissertation projects

Last year, we had the opportunity to speak at Regent’s UX Conference (Regent’s University London’s…

7 days ago