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

Canonical announces 12 year Kubernetes LTS

Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…

18 hours ago

Ubuntu Weekly Newsletter Issue 878

Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…

2 days ago

How your feedback shapes the way we support open source software

At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…

2 days ago

How To Install osTicket v1.14 On Ubuntu 20.04

I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…

3 days ago

How To Install WordPress On Ubuntu 20.04

Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…

3 days ago

How To Install DNS Server (Bind9) On Ubuntu 20.04

Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…

3 days ago