Install OpenSSL on Ubuntu 22.04


OpenSSL is an open-source command-line tool used to perform different cryptographic functions. These functions include encryption, decryption, certificate management, etc. OpenSSL is a widely used SSL/TLS cryptographic protocol to secure communication and transfer data over the internet. The main aim of this article is to demonstrate how to install OpenSSL on Ubuntu 22.04.

The following two methods can be used to install OpenSSL on Ubuntu 22.04:
• Install OpenSSL via apt repository
• Install OpenSSL using wget

Method 1: Install OpenSSL on Ubuntu 22.04 via apt Repository

The steps, as follow, can be used to install OpenSSL on Ubuntu 22.04.

Step 1: Update Ubuntu Repository

Ubuntu is an open-source platform. Therefore it is strongly recommended to keep Ubuntu up to date. The following command will update Ubuntu with the latest updates.

sudo apt update && sudo apt upgrade -y

Install OpenSSL on Ubuntu | linuxgenie.net

The above screenshot illustrates that all the necessary files and dependencies have been installed.

Step 2: Install OpenSSL

To install OpenSSL on Ubuntu 22.04, run the below command from the terminal.

sudo apt install openssl -y

Install OpenSSL on Ubuntu | linuxgenie.net

It can be seen in the above screenshot that the OpenSSL package and dependencies are installed without any error.

Step 3: Verify OpenSSL

Once the OpenSSL is installed, you can verify OpenSSL with the following command.

openssl version

Install OpenSSL on Ubuntu

The above message shows that the latest available version of OpenSSL has been installed on your Ubuntu 22.04.

Method 2: Install OpenSSL Using wget

Check out the provided instructions for installing OpenSSL using wget.

Step 1: Install prerequisites

Sometimes Ubuntu needs dependencies before running the packages. Type the given-below command to handle this kind of issue.

sudo apt install build-essential checkinstall zlib1g-dev -y

Install OpenSSL on Ubuntu

After completion of the process, you will find the message mentioned above.

Step 2: Change the Directory

Run the given-below command to change the working directory to “/usr/local/src.” In Linux, the “/usr/local/src” directory location is used for storing source code.

cd /usr/local/src

Install OpenSSL on Ubuntu

As per the given-above screenshot, the working directory has been changed successfully.

Step 3: Download the Latest file of OpenSSL

In Ubuntu, the wget retrieves the source file from the internet. To download the updated and latest version of OpenSSL, you need to copy the link from the OpenSSL website and use the copied link in the following pattern.

sudo wget https://www.openssl.org/source/openssl-3.1.0.tar.gz

Install OpenSSL on Ubuntu

As per the screenshot attached above, the OpenSSL source code in tar.gz is downloaded in “/usr/local/src.”

Step 4: Extract the openssl-3.1.0.tar.gz File

Once the OpenSSL source code is downloaded, now it’s time to extract the content of the file and use them accordingly. To extract the openssl-3.1.0.tar.gz file, the below-mentioned command can be run from the terminal.

sudo tar -xf openssl-3.1.0.tar.gz

Install OpenSSL on Ubuntu

It can be seen in the above screenshot that the “tar -xf” command has run successfully.

The “ls” command will be used to list the extracted content in the destination folder.

ls

Install OpenSSL on Ubuntu

Step 5: Change the working directory to manipulate the OpenSSL content

Run the given command below to change the working directory and manipulate the OpenSSL content.

cd openssl-3.1.0

Install OpenSSL on Ubuntu

Step 6: OpenSSL configuration

Type the following code in your Ubuntu 22.04 terminal and hit enter to configure the OpenSSL in your Ubuntu system.

sudo ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib

Install OpenSSL on Ubuntu

After successful configuration, you will find the above-mentioned message on your screen that says OpenSSL has been successfully configured.

Step 7: Compile and Install the OpenSSL

At this stage, you need to compile the executable files and install them in your Ubuntu system. The given-below command will compile and install the packages with a single hit enter.

sudo make && sudo make install

Install OpenSSL on Ubuntu

According to the above-mentioned screenshots, the OpenSSL packages are compiled and installed without any error.

Step 8: Verify the OpenSSL

To confirm whether the OpenSSL packages are installed or not, run the below-given command.

openssl version -a

Install OpenSSL on Ubuntu

The “version -a” command displayed all the available information about OpenSSL.

Uninstall OpenSSL from Ubuntu 22.04

The purge command in Ubuntu is used to remove the package files as well as the dependencies. To remove the package and configuration files completely, the below-mentioned “purge” command can be run from the terminal.

sudo apt purge openssl -y

Install OpenSSL on Ubuntu

As shown in the above screenshot, the OpenSSL packages files, configuration, and dependencies have been removed from Ubuntu 22.04.

The “apt autoremove openssl” command can also be used to remove the other dependencies related to OpenSSL:

sudo apt autoremove openssl -y

Install OpenSSL on Ubuntu

It can be seen in the screenshot attached above that the other dependency files have also been removed from your Ubuntu system.

The command “version -a” will be used to show the available information about OpenSSL.

openssl version -a

Install OpenSSL on Ubuntu

As per the above screenshot, there is no OpenSSL file or directory, meaning the OpenSSL has been removed from Ubuntu 22.04.

Bonus Tips

While downloading the OpenSSL source code from the link, you may face authenticity certificate problems, as shown in the below screenshot. But don’t worry, it can be solved with a single-line command.

sudo wget https://www.openssl.org/source/openssl-3.1.0.tar.gz

Install OpenSSL on Ubuntu

The command given below will be used to solve this problem.

sudo apt install ca-certificates -y

Install OpenSSL on Ubuntu

It can be absorbed from the above-mentioned message that the ca-certificates packages are installed in your machine without any error. In Linux, the “ca-certificates” is a trusted root certificate that verifies the authenticity of SSL/TLS connections.

Conclusion

OpenSSL can be installed on Ubuntu 22.04. OpenSSL is a command used to communicate and transfer data securely. In this article, we have practically demonstrated the two different methods of installation and configuration of OpenSSL on Ubuntu. Additionally, we have also illustrated the uninstallation process of OpenSSL.

Print Friendly, PDF & Email