Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 052012
 

How to check if a RSA key file is valid

Answer:

If you have a RSA key file "test.pem" and want to know if it is a valid RSA key, you can perform a quick check

# openssl rsa -in test.pem -check
unable to load Private Key
21315:error:0906D064:PEM routines:PEM_read_bio:bad base64 decode:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/pem/pem_lib.c:763:

If it is valid, you will find

# openssl rsa -in test.pem -check
RSA key ok
Jun 182010
 

Simple file encryption with OpenSSL

Answer:

You have a single file (input.txt), and you want to encrypt it with a password, it is easy with OpenSSL.

# openssl aes-128-cbc -salt -in input.txt-out input.aes

Enter the password twice.

When you want to decrypt it, use the command.

# openssl aes-128-cbc -d -salt -in input.aes -out output.txt