Share secret with SSH public key
Table of Contents
The problem
At times when collaborating with my team mates I am in a situation wherein I would like to quickly share some secret with them, "securely" offcourse! Pasting secrets on slack and quickly deleting them doesn't exactly count as secure!
Quickfix solution
Following is a quick code snippet to use ssh public key to quickly encrypt secret and share it via slack,
- Ask your team mate to send their public key in pem format
openssl rsa -in ~/.ssh/id_rsa -pubout > id_rsa.pub.pem
- Encrypt the secret with the public key
echo "something secret" | openssl rsautl -encrypt -pubin -inkey id_rsa.pub.pem > secret.txt
- Send
secret.txt
file via slack and they can decrypt it as follows,
cat cipher.txt | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa