October 11, 2011 Leave a comment
There are plenty of encryption tools in Linux and some of them are difficult to use like openssl. There are just too many parameters!! So I decided to write a tutorial using examples.
How to create rsa key pairs?
$openssl genrsa -des3 -out myprivate.key 1024
It will generate private key of length 1024. Note that both private and public key is stored in the .key file. To extract your public key:
$openssl rsa -in server.key -out public.pem -outform PEM -pubout
How encrypt a file using aes or rsa?
$openssl rsautl -encrypt -pubin -inkey public.pem -in a.log -out a.log.rsa.enc
This command will encrypt a.log using public key public.pem. Unfortunately, rsautl does NOT support ASCII encoding so you pretty much a block of junk in a.log.rsa.enc