Giter VIP home page Giter VIP logo

secret's Introduction

secret

A simple and tiny tool that will help you keep your little secrets.

Features

secret is the simplest secret store you can think of. But it does have some interesting features:

  • Requires only one file ~/.secret that you can share publicly without fear.
  • No configuration. No directory. Get back your file and you're done.
  • Secret names (usually hostname, mail, login, etc.) are also encrypted.
  • A secret agent that only trusts subprocesses. Not all the processes of the same user!
  • Secret names completion is available after calling the secret agent.
  • Supports unstored secrets. Derived from some simple keys and a passphrase.
  • Supports multiple passphrases. A confirmation is requested for each new passphrase.
  • Supports TOTP natively. The name must contain the word totp.
  • Depends only on the libhydrogen library.
  • Small, simple and non obfuscated C code. Well, I hope so :)

Security

The main goal is to have secret working on all architectures and to make it very simple to audit.

Luckily, permutation-based cryptography has arrived and makes it possible to achieve this goal with very little code. In 2020, using a bloated library full of CVEs will not have been reasonable considering the major advances in this field.

Only one cryptographic building block is used, the Gimli permutation. All cryptographic operations are derived from this permutation and implemented in the libhydrogen library.

Install

Homebrew

You can simply install secret from my Homebrew Tap:

$ brew install angt/tap/secret

Build from source

This should work on a wide variety of architectures and POSIX systems. It was successfully tested on Linux, OpenBSD, FreeBSD and MacOS.

Clone the repository recursively:

$ git clone https://github.com/angt/secret --recursive
$ cd secret

Then, run as root:

# make install

As usual, you can customize the destination with DESTDIR and prefix. Typically if you want to change the default /usr/local prefix:

# make prefix=/usr install

Tab completion

Tab completion works with bash, zsh and yash. Unfortunately, it doesn't work out of the box, you have to setup it manually. Luckily, it's super easy!

Download the file corresponding to your shell:

Then, for bash, you can add these lines in your .bashrc:

. YOUR_PATH_TO/argz.bash

complete -F _argz secret

For yash, in your .yashrc:

. YOUR_PATH_TO/argz.yash

function completion/secret {
    command -f completion//reexecute argz
}

And finally, for zsh, in your .zshrc:

. YOUR_PATH_TO/argz.zsh

compdef _argz secret

Completion for secrets is only available in a trusted shell. See below.

Commands

Available commands:

init       Initialize secret for the current user
list       List all secrets for a given passphrase
show       Print a secret
new        Generate a new random secret
set        Set a new secret
renew      Regenerate an existing secret
update     Update an existing secret
pass       Print a deterministic secret
agent      Run a process in a trusted zone
version    Show version

All secrets are encrypted in the file ~/.secret. You can use a different file with the SECRET_STORE environment variable:

$ env SECRET_STORE=<FILE> secret ...

Examples

Initialize secret for the current user:

$ secret init

Add a new randomly generated secret:

$ secret new test
Passphrase:
No secrets stored with this passphrase.
Please, retype it to confirm:
/xK;{%@d~hPh.L'5-Sn{sBQd5

Show the secret:

$ secret show test
Passphrase:
/xK;{%@d~hPh.L'5-Sn{sBQd5

Rename a secret, press ENTER to not change it:

$ secret update test test2
Passphrase:
Secret:

$ secret show test2
Passphrase:
/xK;{%@d~hPh.L'5-Sn{sBQd5

Pipe a secret:

$ secret show test2 | tr -cd [a-z] | secret update test2
Passphrase:
Passphrase:

$ secret show test2
Passphrase:
xdhhnsd

Add a TOTP token:

$ echo -n JBSWY3DPEHPK3PXP | base32 -d | secret set test/totp
Passphrase:

$ secret show test/totp
Passphrase:
$ 123456

Derive a deterministic (a.k.a. unstored) secret:

$ secret pass [email protected]
Passphrase:
a`4$B2mJ=|"HD?b4:/y"?wOaQ

Subkeys are also supported, this allows to update your secret in a clean way:

$ secret pass [email protected] 2020
Passphrase:
F"1j;-X]t.Pi>.xf5hG,]dUMz

Add a binary secret:

$ dd if=/dev/urandom bs=1 count=32 2>/dev/null | secret set mykey
Passphrase:

$ secret show mykey | xxd
Passphrase:
00000000: 0ee9 cdb3 de0a 3e71 b623 726d 5d7e eb23  ......>q.#rm]~.#
00000010: 5b43 a458 3fb7 3b96 ea9b 6e47 d302 cae7  [C.X?.;...nG....

Start a trusted zone:

$ secret agent
Passphrase:

Now, the passphrase is not requested and completion fully works!

If you don't use bash but still want completion, run secret agent <yourawesomeshell> or (much better) send a PR to add support for your shiny shell :)


For feature requests and bug reports, please create an issue.

secret's People

Contributors

angt avatar jedisct1 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

secret's Issues

Feature Request: passphrase in scripts

I'm a fan of our tool.
I have the following use case:
I have several .secret files .secret_user_x that I would share with different users. The .secret_user_x files contain a key and I can share passwords with users (env /PATH/TO/SECRET/FILE/.secret_user_x secret pass common_secret).
The passphrase for these .secret_user_x file is stored in a main .secret file.
I want to use a script to create and query the .secret_user_x files.

So i have the following feature request:
Would it be possible to pass the passphrase via script. I use expect, but I am not a fan of expect. Would it be possible to call something like this:
echo <PASSPHRASE> | env /PATH/TO/SECRET/FILE/.secret_user_x secret show key
or
secret show passphrase_user_A | env /PATH/TO/SECRET/FILE/.secret_user_x secret show key

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.