Skip to content

Instantly share code, notes, and snippets.

@tashrifbillah
Created December 8, 2023 04:37
Show Gist options
  • Save tashrifbillah/dbd8d1e5d8e8500211a26a099bf4981b to your computer and use it in GitHub Desktop.
Save tashrifbillah/dbd8d1e5d8e8500211a26a099bf4981b to your computer and use it in GitHub Desktop.
Commands for encrypting and decrypting a message using SSH's public/private key pair
#!/bin/bash
# convert SSH public key to pem format
ssh-keygen -e -m PKCS8 -f git_rsa.pub > git_rsa.pem
# encrypt
openssl rsautl -encrypt -pubin -inkey git_rsa.pem -in message.txt -out message.enc
# decrypt
openssl rsautl -decrypt -inkey git_rsa -in message.enc
@tashrifbillah
Copy link
Author

Putting it up here for future Googlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment