How to Install OpenSSL on Debian 12

OpenSSL is a software library that is used for security-related tasks on Linux. It is also known as the fundamental component of the Linux distribution. It is used in securing the remote connections which are using the SSH. Database servers including MySQL also support OpenSSL to secure its connections. 

OpenSSL can be installed on different Linux distributions including Ubuntu and Debian. This post explains the installation methods for the OpenSSL on Debian 12 using the Terminal. 

What are the Installation Methods for OpenSSL on Debian 12?

One can install OpenSSL on Debian 12 using one of the two methods listed below:

  1. Using the Default Repository’s Package
  2. Using the Source Code

Method 1: Install OpenSSL on Debian 12 Using the Default Repository’s Package

The first recommended method is to install the packages on Debian 12 using the package available in its default repository. Use the next-mentioned steps to install OpenSSL using the default package.

Step 1: Launch the Terminal

With the CTRL+ALT+T shortcuts key, open and launch the terminal of Debian 12 to run the commands:

Step 2: Update the Packages

Once the terminal is launched, use the “update” option of the apt command to ensure all the packages are up to date:

$ sudo apt update

Step 3: Search for the OpenSSL Package

Now search for the available version of the OpenSSL package on Debian:

$ sudo apt show openssl

Step 4: Install OpenSSL on Debian

To install the available package of the OpenSSL on Debian, use the command:

$ sudo apt install openssl -y

Step 5: Verify the Installation

Display the installed version of the OpenSSL on Debian to verify its installation:

$ openssl version

OpenSSL has successfully installed on Debian 12 by using the installation package available in its default repository. 

How to Uninstall OpenSSL on Debian 12?

To remove and uninstall the package of OpenSSL on Debian 12 with its all configuration files, run the command:

$ sudo apt purge openssl -y

Also, remove all the packages which are not being used by the system for a long time:

$ sudo apt autoremove -y

Method 2: Install OpenSSL on Debian 12 Using the Source Code

Another method of installing the OpenSSL on Debian 12 is by using its source code. Execute the commands listed in the steps below to do this. 

Step 1: Navigate to the Directory

First, navigate to the directory where it is supposed to download the package of OpenSSL:

$ cd /usr/local/src

Step 2: Download the OpenSSL

Download the OpenSSL package from the “Downloads” section of its official website. This can also be downloaded with the wget command:

$ sudo wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1w.tar.gz

Confirm the downloading by extracting the contents of the directory using the command:

$ ls

Step 3: Extract the tar Folder

Now extract the downloaded tar installation folder of the OpenSSL with the command:

$ sudo tar -xf openssl-1.1.1w.tar.gz

Step 4: Navigate to the OpenSSL Directory

When the tar directory is extracted, navigate to the extracted directory of OpenSSL:

$ cd openssl-1.1.1w

Step 5: Install configuration of OpenSSL

Install the configuration files of the OpenSSL with the execution of the command:

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

Step 6: Compile the OpenSSL

Now compile all the binaries of the OpenSSL:

$ sudo make

Step 7: Install OpenSSL on Debian 12

When the compilation of the OpenSSL binaries are completed, then install them using the command:

$ sudo make install

Step 8: Verify the Installation

To verify the installation, again display the version of it:

$ /usr/local/ssl/bin/openssl version

These are the two different methods by which OpenSSL can be installed on Debian 12.

Conclusion

To install OpenSSL on Debian 12, either run the “sudo apt install openssl” in the terminal or download the source package from its official website. In this tutorial’s step-by-step guidance, both techniques are explained in detail. The installation using the source package is used to install the latest version of the OpenSSL on Debian 12.