Linux Command: openssl
OpenSSL command line tool for cryptography and SSL/TLS
openssl is a cryptographic toolkit for SSL/TLS operations, certificate management, encryption, hashing, and key generation. It is the Swiss Army knife of cryptography on Linux. openssl is used for generating SSL certificates, creating certificate signing requests (CSRs), testing SSL connections, encrypting/decrypting files, and generating random data. For web servers, openssl is essential for generating private keys, creating CSRs for certificate authorities, and converting between certificate formats (PEM, DER, PFX).
Syntax
openssl COMMAND [OPTION]...Key Options
genrsaโ Generate RSA private keyreqโ Create certificate signing requestx509โ Create/examine X.509 certificatess_clientโ Test SSL/TLS connectionencโ Encrypt/decrypt filesrandโ Generate random data
Examples
Generate private key
openssl genrsa -out server.key 4096Output: Generating RSA private key, 4096 bit long modulus
Generate CSR
openssl req -new -key server.key -out server.csrSelf-signed certificate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodesPro Tips
- echo | openssl s_client -connect host:443 2>/dev/null | openssl x509 -text quickly shows any server certificate.
- Private keys must be 600 permissions and never shared. chmod 600 server.key immediately after generation.
- For production SSL certificates, use certbot (Let's Encrypt) instead of self-signed. openssl is for testing and CSR generation.
Learn more: Full openssl reference โ
Related Resources