UbuntuUbuntu Based

How To Install OpenSSL on Ubuntu 22.04 LTS

Install OpenSSL on Ubuntu 22.04

In this tutorial, we will show you how to install OpenSSL on Ubuntu 22.04 LTS. For those of you who didn’t know, OpenSSL is a widely-used open-source implementation of the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols, which are used to secure communications over a network. It provides a library of cryptographic functions and command-line tools to use them, including symmetric ciphers, public-key ciphers, and hashing functions, as well as functions for managing digital certificates and certificate signing requests. OpenSSL is also used as a foundation for many other software libraries and tools, however, it’s important to keep your version of OpenSSL up-to-date to avoid known vulnerabilities.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the latest OpenSSL on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for OpenSSL.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install OpenSSL on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

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

Step 2. Installing OpenSSL on Ubuntu 22.04 LTS.

By default, OpenSSL is not available on the Ubuntu base repository. Now run the following command below to download the latest source code of OpenSSL to your Ubuntu system:

cd /usr/local/src/
wget https://www.openssl.org/source/openssl-3.0.7.tar.gz

When the download is complete, proceed to extract the archive contents to your system:

tar -xf openssl-3.0.7.tar.gz
cd openssl-3.0.7

Before proceeding with the installation, change to the OpenSSL directory you extracted. To verify that you are in the correct location, list its contents by typing “ls“:

ls
ACKNOWLEDGEMENTS.md  HACKING.md        NOTES-PERL.md      README-PROVIDERS.md  build.info        e_os.h    providers
AUTHORS.md           INSTALL.md        NOTES-UNIX.md      README.md            config            engines   ssl
CHANGES.md           LICENSE.txt       NOTES-VALGRIND.md  SUPPORT.md           config.com        external  test
CONTRIBUTING.md      NEWS.md           NOTES-VMS.md       VERSION.dat          configdata.pm.in  fuzz      tools
Configurations       NOTES-ANDROID.md  NOTES-WINDOWS.md   VMS                  crypto            include   util
Configure            NOTES-DJGPP.md    README-ENGINES.md  apps                 demos             ms        wycheproof
FAQ.md               NOTES-NONSTOP.md  README-FIPS.md     appveyor.yml         doc               os-dep

Let’s check the installed version using the command below:

openssl version -a

Next, we compile from the source, and run the following command:

cd /usr/local/src/openssl-3.0.7
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make
make test

Output:

Configuring OpenSSL version 3.0.7 for target linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Running configdata.pm
Creating Makefile.in
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************

Please wait for the compiler to finish before continuing with the make install command:

make install

After successfully installing OpenSSL, continue by configuring the library paths:

cd /etc/ld.so.conf.d/
nano openssl-3.0.7.conf

Paste the OpenSSL library path directory:

/usr/local/ssl/lib64

Save and close the file, then reload the dynamic link using the command below:

sudo ldconfig -v

Step 3. Configure OpenSSL Binary.

We need to replace the OpenSSL binary found in /usr/bin/openssl or /bin/openssl with the new version in /usr/local/ssl/bin/openssl. First back up the existing files:

mv /usr/bin/c_rehash /usr/bin/c_rehash.bak
mv /usr/bin/openssl /usr/bin/openssl.bak

Next, edit the ‘/etc/environment‘ file using favorite your text editor:

nano /etc/environment

Add the new OpenSSL binary directory:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/ssl/bin"

Save and close the file, then reloading the environment variable is necessary:

source /etc/environment
echo $PATH

Now we check the OpenSSL binary file again using the following command:

which openssl

Congratulations! You have successfully installed OpenSSL. Thanks for using this tutorial for installing the latest OpenSSL on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the OpenSSL website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button