How to Set Up SSH Keys on Ubuntu 22.04

Secure Shell Technology or SSH is a network communication protocol that permits two systems to securely communicate in an unsecured network. This cryptographic protocol is also utilized for commandline executables or remote login programs such as terminal applications. Users who want to use SSH for connecting to other remote systems must have SSH configured on both client and server machines.

This write-up will demonstrate the method to set up SSH keys on Ubuntu 22.04. So, let’s start!

How to set up SSH keys on Ubuntu 22.04

Want to set up SSH keys on your Ubuntu 22.04 system? If yes, then check out the following step-by-step procedure.

Step
Sponsored
1: Update system repositories

First of all, open up the terminal by hitting “CTRL+ALT+T” in Ubuntu 22.04 and write out the below-given commands for updating the system repositories:

$ sudo apt update

Upgrade the system packages as well:

$ sudo apt upgrade

Step 2: OpenSSH installation

In the next step, execute the below-given command to install OpenSSH on your Ubuntu 22.04:

$ sudo apt install openssh-server -y

Wait for a few minutes, as the installation of OpenSSH will take some time to complete:

Step 3: Enable SSH

Then, enable SSH by utilizing the given command “systemctl” command:

$ sudo systemctl enable –now ssh

Step 4: Verify SSH status

After successful installation of OpenSSH and enabling the SSH on Ubuntu 22.04, you must validate the current SSH status to check if it is active or not:

$ sudo systemctl status ssh

The below-given output signifies that we have SSH is active and running on our system:

Step 5: Configure Firewall

Now, it’s time to configure Firewall to allow the connections for port “22”:

$ sudo ufw allow 22/tcp

Then, enable your UFW Firewall on Ubuntu 22.04 system:

Sponsored
$ sudo ufw enable

Step 6: Connect to a remote system via SSH

At this point, we have successfully set up SSH on Ubuntu 22.04, and our system is now all ready to connect to a remote system. Make sure that OpenSSH is also installed on the corresponding server.

For the purpose of connecting to an SSH server, you have to utilize their “username” and “IP address” in the following way:

$ ssh username@ip-address.

For instance, to connect with the “linuxuser-VBox” system with the IP address “10.0.2.15”:

$ ssh linuxuser-VBox@10.0.2.15

At the first-time connection with the specified system; you will be asked to verify if you want to establish a connection or not, so, enter “yes” to move ahead:

Then, type out your system password, and within few mini seconds your system will be connected to the specified remote system:

You can also list down the directories of the connected system with the help of the “ls” command:

$ ls

The output of the “ls” command will verify if the remote connection is successfully established or not:

After performing the required operation on the connected remote system, you can disable SSH with the help of the following command:

$ sudo systemctl disable ssh –now

How to uninstall SSH from Ubuntu 22.04

To uninstall SSH from Ubuntu 22.04, write-out the following command in terminal:

$ sudo apt autoremove openssh-server -y

We have compiled the easiest method to set up SSH on Ubuntu 22.04. Give it a try to establish a connection with any remote system.

Conclusion

To set SSH on Ubuntu 22.04, firstly, install the OpenSSH server by utilizing the “$ sudo apt install openssh-server -y” command. Then, configure the Firewall to open port “22” with the “$ sudo ufw allow 22/tcp” command. After doing so, enable UFW Firewall and execute the “$ ssh username@ip-address” command for connecting to a remote system. This write-up discussed the method to set up SSH on Ubuntu 22.04.

Ubuntu Server Admin

Recent Posts

How to Fix VMware’s “Could not open /dev/vmmon” Error on Ubuntu

You’ve recently installed VMware Workstation on your Ubuntu system and encountered the frustrating “Could not…

4 hours ago

How to Fix Ubuntu 404 Errors While Fetching Dependencies

Have you ever found yourself staring at a terminal full of 404 errors while trying…

4 hours ago

How to Fix ‘Please Install All Available Updates’ Error When Upgrading Ubuntu 18.04 to 20.04 LTS

One particularly frustrating error that many users face when trying to upgrade from Ubuntu 18.04 …

4 hours ago

How to fix “Release is not valid yet” Error in Docker Containers

In the world of containerization, time synchronization issues can create unexpected roadblocks when working with…

4 hours ago

How to fix “Externally Managed Environment” Pip Errors on Ubuntu

If you’ve recently upgraded to Ubuntu 23.04 or newer, you might have encountered a frustrating…

4 hours ago

Ubuntu now officially supports NVIDIA Jetson: powering the future of AI at the edge

Canonical announces the General Availability of Ubuntu for the NVIDIA® Jetson Orin™ for edge AI…

11 hours ago