How to set up ssh keys on ubuntu 22. 04

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

How to set up ssh keys on ubuntu 22. 04

Upgrade the system packages as well:

$ sudo apt upgrade

How to set up ssh keys on ubuntu 22. 04 1

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

How to set up ssh keys on ubuntu 22. 04 2

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

How to set up ssh keys on ubuntu 22. 04 3

Step 3: Enable SSH

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

$ sudo systemctl enable –now ssh

How to set up ssh keys on ubuntu 22. 04 4

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:

How to set up ssh keys on ubuntu 22. 04 5

Step 5: Configure Firewall

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

$ sudo ufw allow 22/tcp

How to set up ssh keys on ubuntu 22. 04 6

Then, enable your UFW Firewall on Ubuntu 22.04 system:

Sponsored
$ sudo ufw enable

How to set up ssh keys on ubuntu 22. 04 7

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:

How to set up ssh keys on ubuntu 22. 04 8

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

How to set up ssh keys on ubuntu 22. 04 9

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

See also  Setup Selenium with Python and Chrome on Ubuntu & Debian
$ ls

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

How to set up ssh keys on ubuntu 22. 04 10

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 set up ssh keys on ubuntu 22. 04 11

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

How to set up ssh keys on ubuntu 22. 04 12

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.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply