Monday, July 21, 2014

encrypting/decrypting files using gpg

Typically you should never transmit any SSH keys over the network or emails. However, in some cases, you may need to encrypt them and move them into a vault or software. In such cases, you could use GnuPG package.

Encrypt:-

$tar cvz keys.tar.gz *.pem | gpg -c -o keys.tar.gz.gpg
tar: keys.tar.gz: Cannot stat: No such file or directory
test.pem
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
Enter passphrase: tar: Exiting with failure status due to previous errors

Decrypt:-

$gpg -d keys.tar.gz.gpg | tar xvz
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
test.pem

No comments:

Post a Comment