Linux Commands Examples

A great documentation place for Linux commands

openssl

OpenSSL command line tool


see also : passwd

Synopsis

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!

examples

1
source
            
openssl openssl.gdb
1
source

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

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

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.

0
source

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 http://packages.debian.org/search?suite=wheezy&searchon=names&keywords=openssl) and means you get future updates with no extra effort.

0
source

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.

0
source

How to install self signed certificate on Apache in Linux?

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

http://www.akadia.com/services/ssh_test_certificate.html

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

0
source

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.

0
source

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.

0
source

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.

0
source

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.

0
source

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
update-ca-certificates

In debian alike it should be:

apt-get install ca-certificates
update-ca-certificates

0
source

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.

0
source

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.)

0
source

libcrypt.a undefined reference to NSSLOW_

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

http://blog.gmane.org/gmane.linux.distributions.gobo.general/month=20100601

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

0
source

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.

description

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.)

STANDARD COMMANDS

asn1parse

Parse an ASN .1 sequence.

ca

Certificate Authority ( CA ) Management.

ciphers

Cipher Suite Description Determination.

cms

CMS (Cryptographic Message Syntax) utility

crl

Certificate Revocation List ( CRL ) Management.

crl2pkcs7

CRL to PKCS#7 Conversion.

dgst

Message Digest Calculation.

dh

Diffie-Hellman Parameter Management. Obsoleted by dhparam.

dhparam

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

dsa

DSA Data Management.

dsaparam

DSA Parameter Generation and Management. Superseded by genpkey and pkeyparam

ec

EC (Elliptic curve) key processing

ecparam

EC parameter manipulation and generation

enc

Encoding with Ciphers.

engine

Engine (loadble module) information and manipulation.

errstr

Error Number to Error String Conversion.

gendh

Generation of Diffie-Hellman Parameters. Obsoleted by dhparam.

gendsa

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

genpkey

Generation of Private Key or Parameters.

genrsa

Generation of RSA Private Key. Superceded by genpkey.

nseq

Create or examine a netscape certificate sequence

ocsp

Online Certificate Status Protocol utility.

passwd

Generation of hashed passwords.

pkcs12

PKCS#12 Data Management.

pkcs7

PKCS#7 Data Management.

pkey

Public and private key management.

pkeyparam

Public key algorithm parameter management.

pkeyutl

Public key algorithm cryptographic operation utility.

rand

Generate pseudo-random bytes.

req

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

rsa

RSA key management.

rsautl

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

s_client

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.

s_server

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.

s_time

SSL Connection Timer.

sess_id

SSL Session Data Management.

smime

S/MIME mail processing.

speed

Algorithm Speed Measurement.

spkac

SPKAC printing and generating utility

ts

Time Stamping Authority tool (client/server)

verify

X.509 Certificate Verification.

version

OpenSSL Version Information.

x509

X.509 Certificate Data Management.

MESSAGE DIGEST COMMANDS

md2

MD2 Digest

md5

MD5 Digest

mdc2

MDC2 Digest

rmd160

RMD-160 Digest

sha

SHA Digest

sha1

SHA-1 Digest

sha224

SHA-224 Digest

sha256

SHA-256 Digest

sha384

SHA-384 Digest

sha512

SHA-512 Digest

ENCODING AND CIPHER COMMANDS

base64

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-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

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.
pass:password

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.

env:var

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.

file:pathname

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.

fd:number

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

stdin

read the password from standard input.


history

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