Code Monkey home page Code Monkey logo

sshenc.sh's Introduction

sshenc.sh

bash script to encrypt data using a users ssh public key

If you received a message from someone that was encrypted with this script, you can decrypt it with your ssh private key using the following command without installing anything:

bash <(curl -s https://raw.githubusercontent.com/5im-0n/sshenc.sh/master/sshenc.sh) -s ~/.ssh/id_rsa < file-containing-the-encrypted-text.txt

sshenc.sh uses openssl under the hood, so you need to have that installed in your path to make it work.

Install

curl -O https://raw.githubusercontent.com/5im-0n/sshenc.sh/master/sshenc.sh
chmod +x sshenc.sh

Examples

encrypt a file using your own ssh public key

sshenc.sh -p ~/.ssh/id_rsa.pub < plain-text-file.txt > encrypted.txt

encrypt a file using multiple recipients (broadcast encryption)

sshenc.sh -p ~/.ssh/id_rsa.pub -p id_rsa-alice.pub -p id_rsa-bob.pub < plain-text-file.txt > encrypted.txt

encrypt a file using the public key of a github user

sshenc.sh -g S2- < plain-text-file.txt

this line fetches the public keys for the github user S2- and encrypts the file plain-text-file.txt using its key(s).

decrypt a file

sshenc.sh -s ~/.ssh/id_rsa < encrypted.txt

Notes

OpenSSL 1.1.1 introduced a not backwards compatible change: the default digest to create a key from the passphrase changed from md5 to sha-256.
Also, a new -iter parameter to explicitly specify a given number of iterations on the password in deriving the encryption key was added.
Before OpenSSL 1.1.1 this option was not available.
Since the new parameters are more secure, sshenc.sh changed to adopt them, so since 2019-11-26, files encrypted with a previous version of sshenc.sh will not decrypt.
To do so, use the prevous sshenc.sh script, located at https://raw.githubusercontent.com/5im-0n/sshenc.sh/master/sshenc-pre1.1.1.sh.

License

MIT

sshenc.sh's People

Contributors

5im-0n avatar bernardm avatar gfa avatar pete-woods avatar shahzaib-sheikh avatar sutra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sshenc.sh's Issues

Feature request: support other key types besides rsa

As most in the know have switched away from rsa to ecdsa or ed25519 keys how hard would it be to support other key types.
openssh supports:

  • dsa
  • ecdsa
  • ed25519
  • rsa

this would make sshenc.sh more versatile in secure environments.

Retain pre-openssl1.1.1 tests for legacy users

Can we retain (re-add) tests.sh with different name like tests-pre1.1.1.sh for sshenc-pre1.1.1.sh. It would be helpful for people who are not able to get openssl1.1.1 on their machine. Glad to see the changes, but somehow I'm not able to run the new version on my machine openssl version -a returns this
LibreSSL 2.8.3
built on: date not available
platform: information not available
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"

could you advise what steps are needed to be able to run the 1.1.1 compatible changes.
Thanks.

new openssh private key format

~λ openssl rsautl -decrypt -ssl -inkey .ssh/id_rsa
unable to load Private Key
139994616321280:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY

jeroen/openssl#66

Add option to use a file instead of stdin for decryption

First of all thanks for building this tool! ❤️

But it seems to fail if the ssh key is protected with a password. At least on my system I get prompted for a password in this line

install -m 0600 "$private_key" "$temp_dir/private_key"

That conflicts with the encrypted data I am already shoving down stdin. So it reads it as password and fails because the password is wrong. It would be nice to allow reading from a file instead of reading from stdin. To keep stdin free for password prompts.

Something along the lines of changing this

stdin=`cat`

to stdin="$(cat "$encrypted_file")"

And the decrypt command from this

sshenc.sh -s ~/.ssh/id_rsa < encrypted.txt

to this

sshenc.sh -s ~/.ssh/id_rsa -f encrypted.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.