Linux Commands Examples

A great documentation place for Linux commands


OpenSSL command line tool

see also : passwd


openssl command [ command_opts ] [ command_args ]

openssl [ list-standard-commands | list-message-digest-commands | list-cipher-commands | list-cipher-algorithms | list-message-digest-algorithms | list-public-key-algorithms]

openssl no- XXX [ arbitrary options ]

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


openssl openssl.gdb

Openssl decrypt from encrypted text from command issue

Try something like this:

openssl rsautl -decrypt -in binarytext -out myfile.txt -inkey private.pem

The important bit here is -out myfile.txt

optional_depends openssl \
"--enable-openssl" \
"--enable-openssl" \
"--disable-openssl" \
"for openssl encryption support"
openssl rand -hex $1

OpenSSL missing during ./configure. How to fix?

Yes, it's a mandatory step. You cannot remove OpenSSL from a program uses it, the same way you couldn't remove random engine parts from a car.

The OpenSSL library is usually already installed, but you have to install the header files. Depending on your Linux distribution, you'll need these packages:

  • Red Hat, Fedora, CentOS - openssl-devel
  • Debian, Ubuntu - libssl-dev
  • Arch - openssl

Technically one could replace OpenSSL with, say, NSS, but that's not the point here.


updating openssl on Debian

OpenSSL is often considered a core package as it is used by a number of others to provide security features, and I would recommend against hand-rolling core packages unless you have a particularly good understanding of the potential repercussions. If you do hand-roll it I would recommend installing over the provided package, instead installing it into /usr/local or even your user home and compiling what-ever you need that needs the updated library where to find it as pat of their build procedure - this was you do not disrupt other binary packages that depend upon openssl. If you hand-roll openssl you will need to rebuild it each time an update is released (and may need to rebuild other dependent packes each time too depending on the changes).

Would it be possible to instead update your Debian installation to the latest Stable instead? That includes v1.0.1e by default (see and means you get future updates with no extra effort.


Permissions for SSL key?

Private keys should have reading heavily restricted. Setting permissions to 600 and owned by root should work. However, there are other secure permissions settings - Ubuntu stores keys in a directory with owner root and group ssl-cert and permissions 710. This means that only members of ssl-cert can access any files in that directory. Private keys then have group ssl-cert, owner root, and permissions 640.


How to install self signed certificate on Apache in Linux?

This should help you get a Self Signed Cert made and set up:

It's pretty straight forward. It looks like you skipped the Step 2 and need to change the way you're doing step 4.


Trying to install libcurl on a Linux RHEL, unable to install openssl

On this system, you have installed an RHEL 6 openssl x86-64 RPM, but you're trying to install an order RHEL 5 openssl i386 RPM. You need to install an i386 version of openssl that matches your x86-64 RPM.

The easiest way to install this would be to use yum rather than rpm. The command to install via yum (with all dependencies) is:

yum -y install libcurl.i386

If you can't do that for some reason, get the openssl package you need from the RHEL updates repository, or you can use the latest openssl RPM from CentOS 6.


Why does Openssl 0.9.8g suddenly changes to 0.9.8b?

The answer is encoded below:

sudo find / -name 'libssl*'

Chances are there is more than one libssl on your machine. You can find the version number by doing something like strings - /usr/lib/libssl* | less and then search for the version number by typing /0\.9\.8 followed by ENTER.


How do I use cat to encrypt stdin on the fly with openssl?

If you type

cat | openssl enc -base64

and then press Ctrl + D then it will encode everything you just typed.


yum update to the specific version of package

You can only update to whatever version of the openssl package is available in the yum repositories. You can check to see which openssl package is available by entering the command:

yum list available openssl

On RHEL5, the version available at this time is openssl-0.9.8e-22.el5_8.4.

On RHEL6, the current version is openssl-1.0.0-27.el6.

If you are on an RHEL5 or CentOS5 machine, you cannot update to the openssl-1.0.0 package that is only available for RHEL6 or CentOS6.


Error with curl

Fix. I don't know what the problem was, but it was related to the certificates (ca-certificates) package.

It was fixed by adding ca-certificates and run update-ca-certificates

The distro I was using is Alpine LInux, so the commands are:

apk add ca-certificates

In debian alike it should be:

apt-get install ca-certificates


Installing openssl on RHEL 6.2

Have you tried making sure you have up to date information in your RPM databases? Something along the lines yum clean all && yum update might be in order at this point.


What's a good database-backed X.509 certificate authority on Linux

I'd recommend OpenCA PKI. I had a good look around for this sort of thing a while ago, and it's the only thing that fit the bill. I've not been rigorous, but the software seems good; the documentation, however, is sorely lacking. This PDF file should help you get up and running. They also have an OCSP responder you can use (which I haven't yet tried).

I tested this software a while ago, but haven't yet put it in production. You can run PostgreSQL or MySQL, and I believe I'd have been using it with MySQL (my preference) but can't absolutely recall. I stopped using it because I got distracted with other projects, not because the software wasn't working.

I remember being very impressed with OpenCA. (For the record, I'm not affiliated with the project at all.)


libcrypt.a undefined reference to NSSLOW_

apparently libcrypt.a was replaced somewhere in the process. We had to custom build using some help from

configuring with

configure --prefix=glibc-2.12-1.47. el6_2.9.src/glibc-2.12-2-gc4ccff1/binary --host=i686-redhat-linux --build=i686-redhat-linux --enable-static --disable-nss-crypt CC='gcc -Wa,--32 -m32' CXX='g++ -Wa,--32 -m32' CFLAGS='-O2 -march=i686' CXXFLAGS='-O2 -march=i686' LDFLAGS=-m32


How to add Openvpn clients without the original rsa folder?

You need the private key (possibly cacert.key if you've been following tutorials) of the CA certificate (cacert.crt) that's in the OpenVPN file, so you can issue new certificates signed by that CA certificate.

If you do not have this private key (typically a .key or .pem file) then you cannot issue any more client certificates, nor can you issue revocation lists. You'll need to create a new CA and new server and client certificates signed by it in that case.

Your only other option is to modify the server configuration to accept passwords in addition to certificates, which is less secure than just accepting certificates.


OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer ( SSL v2/v3) and Transport Layer Security ( TLS v1) network protocols and related cryptography standards required by them.

The openssl program is a command line tool for using the various cryptography functions of OpenSSL’s crypto library from the shell. It can be used for

 o  Creation and management of private keys, public keys and parameters
 o  Public key cryptographic operations
 o  Creation of X.509 certificates, CSRs and CRLs
 o  Calculation of Message Digests
 o  Encryption and Decryption with Ciphers
 o  SSL/TLS Client and Server Tests
 o  Handling of S/MIME signed or encrypted mail
 o  Time Stamp requests, generation and verification

command summary

The openssl program provides a rich variety of commands (command in the SYNOPSIS above), each of which often has a wealth of options and arguments (command_opts and command_args in the SYNOPSIS ).

The pseudo-commands list-standard-commands, list-message-digest-commands, and list-cipher-commands output a list (one entry per line) of the names of all standard commands, message digest commands, or cipher commands, respectively, that are available in the present openssl utility.

The pseudo-commands list-cipher-algorithms and list-message-digest-algorithms list all cipher and message digest names, one entry per line. Aliases are listed as:

 from => to

The pseudo-command list-public-key-algorithms lists all supported public key algorithms.

The pseudo-command no- XXX tests whether a command of the specified name is available. If no command named XXX exists, it returns 0 (success) and prints no- XXX ; otherwise it returns 1 and prints XXX . In both cases, the output goes to stdout and nothing is printed to stderr. Additional command line arguments are always ignored. Since for each cipher there is a command of the same name, this provides an easy way for shell scripts to test for the availability of ciphers in the openssl program. (no- XXX is not able to detect pseudo-commands such as quit, list-...-commands, or no- XXX itself.)



Parse an ASN .1 sequence.


Certificate Authority ( CA ) Management.


Cipher Suite Description Determination.


CMS (Cryptographic Message Syntax) utility


Certificate Revocation List ( CRL ) Management.


CRL to PKCS#7 Conversion.


Message Digest Calculation.


Diffie-Hellman Parameter Management. Obsoleted by dhparam.


Generation and Management of Diffie-Hellman Parameters. Superseded by genpkey and pkeyparam


DSA Data Management.


DSA Parameter Generation and Management. Superseded by genpkey and pkeyparam


EC (Elliptic curve) key processing


EC parameter manipulation and generation


Encoding with Ciphers.


Engine (loadble module) information and manipulation.


Error Number to Error String Conversion.


Generation of Diffie-Hellman Parameters. Obsoleted by dhparam.


Generation of DSA Private Key from Parameters. Superseded by genpkey and pkey


Generation of Private Key or Parameters.


Generation of RSA Private Key. Superceded by genpkey.


Create or examine a netscape certificate sequence


Online Certificate Status Protocol utility.


Generation of hashed passwords.


PKCS#12 Data Management.


PKCS#7 Data Management.


Public and private key management.


Public key algorithm parameter management.


Public key algorithm cryptographic operation utility.


Generate pseudo-random bytes.


PKCS#10 X.509 Certificate Signing Request ( CSR ) Management.


RSA key management.


RSA utility for signing, verification, encryption, and decryption. Superseded by pkeyutl


This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS . It’s intended for testing purposes only and provides only rudimentary interface functionality but internally uses mostly all functionality of the OpenSSL ssl library.


This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS . It’s intended for testing purposes only and provides only rudimentary interface functionality but internally uses mostly all functionality of the OpenSSL ssl library. It provides both an own command line oriented protocol for testing SSL functions and a simple HTTP response facility to emulate an SSL/TLS-aware webserver.


SSL Connection Timer.


SSL Session Data Management.


S/MIME mail processing.


Algorithm Speed Measurement.


SPKAC printing and generating utility


Time Stamping Authority tool (client/server)


X.509 Certificate Verification.


OpenSSL Version Information.


X.509 Certificate Data Management.



MD2 Digest


MD5 Digest


MDC2 Digest


RMD-160 Digest


SHA Digest


SHA-1 Digest


SHA-224 Digest


SHA-256 Digest


SHA-384 Digest


SHA-512 Digest



Base64 Encoding

bf bf-cbc bf-cfb bf-ecb bf-ofb

Blowfish Cipher

cast cast-cbc

CAST Cipher

cast5-cbc cast5-cfb cast5-ecb cast5-ofb

CAST5 Cipher

des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb

DES Cipher

des3 desx des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb

Triple-DES Cipher

idea idea-cbc idea-cfb idea-ecb idea-ofb

IDEA Cipher

rc2 rc2-cbc rc2-cfb rc2-ecb rc2-ofb

RC2 Cipher


RC4 Cipher

rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb

RC5 Cipher

pass phrase arguments

Several commands accept password arguments, typically using -passin and -passout for input and output passwords respectively. These allow the password to be obtained from a variety of sources. Both of these options take a single argument whose format is described below. If no password argument is given and a password is required then the user is prompted to enter one: this will typically be read from the current terminal with echoing turned off.

the actual password is password. Since the password is visible to utilities (like ’ps’ under Unix) this form should only be used where security is not important.


obtain the password from the environment variable var. Since the environment of other processes is visible on certain platforms (e.g. ps under certain Unix OSes) this option should be used with caution.


the first line of pathname is the password. If the same pathname argument is supplied to -passin and -passout arguments then the first line will be used for the input password and the next line for the output password. pathname need not refer to a regular file: it could for example refer to a device or named pipe.


read the password from the file descriptor number. This can be used to send the data via a pipe for example.


read the password from standard input.


The openssl(1) document appeared in OpenSSL 0.9.2. The list- XXX -commands pseudo-commands were added in OpenSSL 0.9.3; The list- XXX -algorithms pseudo-commands were added in OpenSSL 1.0.0; the no- XXX pseudo-commands were added in OpenSSL 0.9.5a. For notes on the availability of other commands, see their individual manual pages.

see also

asn1parse, ca, config, crl, crl2pkcs7, dgst, dhparam, dsa, dsaparam, enc, gendsa, genpkey, genrsa, nseq, openssl, passwd , pkcs12, pkcs7, pkcs8, rand, req, rsa, rsautl, s_client, s_server, s_time, smime, spkac, verify, version, x509, crypto, ssl, x509v3_config

How can this site be more helpful to YOU ?

give  feedback