Advertisement
M2F0

Encrypting files with rsa key pairs

Dec 4th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. 1. Create or open a file that you would like to encrypt.
  2. ➜ ~ echo "my super secret information" > secret.txt ➜ ~ cat secret.txt my super secret information
  3. 2. If you havent already create a rsa key pair. If you would like to use existing rsa key pair skip this step and continue to step 3.
  4. ssh-keygen
  5. 3. Convert your generated or existing public key to pem format.
  6. openssl rsa -in ~/.ssh/id_rsa -pubout > ~/id_rsa.pub.pem
  7. 4. Now you are ready encrypt the file you created earliear.
  8. cat secret.txt | openssl rsautl -encrypt -pubin -inkey ~/id_rsa.pub.pem > encrypted-secret.txt cat encrypted-secret.txt ????uG?????$?&?????VN?'?(????,þQaE咫:?i??t?(?jr.g?#?ջO???=*?e??<"?y'%
  9. 5. To decypt the secret
  10. ➜ ~ cat encrypted-secret.txt | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa my super secret information
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement