Giter Club home page Giter Club logo

pwd.sh's Introduction

pwd.sh is a Bash shell script to manage passwords and other text-based secrets.

It uses GnuPG to symmetrically (i.e., using a passphrase) encrypt and decrypt plaintext files.

Each password is encrypted individually as a randomly-named file in the "safe" directory. An encrypted index is used to map usernames to the respective password file. Both the index and password files can also be decrypted directly with GnuPG without this script.

Install

For the latest version, clone the repository or download the script directly:

git clone https://github.com/drduh/pwd.sh

wget https://raw.githubusercontent.com/drduh/pwd.sh/master/pwd.sh

Versioned Releases are also available.

Use

Run the script interactively using ./pwd.sh or symlink to a directory in PATH:

  • w to write a password
  • r to read a password
  • l to list passwords
  • b to create an archive for backup
  • h to print the help text

Options can also be passed on the command line.

Create a 20-character password for userName:

./pwd.sh w userName 20

Read password for userName:

./pwd.sh r userName

Passwords are stored with an epoch timestamp for revision control. The most recent version is copied to clipboard on read. To list all passwords or read a specific version of a password:

./pwd.sh l

./pwd.sh r userName@1574723600

Create an archive for backup:

./pwd.sh b

Restore an archive from backup:

tar xvf pwd*tar

Configure

Several customizable options and features are also available, and can be configured with environment variables, for example in the shell rc file:

Variable Description Default Available options
PWDSH_COPY clipboard to use xclip pbcopy on macOS
PWDSH_COPY_ARGS arguments to pass to clipboard command unset (disabled) -i -selection clipboard to use primary (control-v) clipboard with xclip
PWDSH_TIME seconds to clear password from clipboard/screen 10 any valid integer
PWDSH_LEN default password length 14 any valid integer
PWDSH_COPY copy password to clipboard before write unset (disabled) 1 or true to enable
PWDSH_DAILY create daily backup archive on write unset (disabled) 1 or true to enable
PWDSH_CHARS character set for passwords [:alnum:]!?@#$%^&*();:+= any valid characters
PWDSH_COMMENT unencrypted comment to include in index and safe files unset any valid string
PWDSH_DEST password output destination, will set to screen without clipboard clipboard clipboard or screen
PWDSH_ECHO character used to echo password input * any valid character
PWDSH_SAFE safe directory name safe any valid string
PWDSH_INDEX index file name pwd.index any valid string
PWDSH_BACKUP backup archive file name pwd.$hostname.$today.tar any valid string
PWDSH_PEPPER file containing "pepper" value, see Detail 1 unset (disabled) any valid file path

See config/gpg.conf for additional GnuPG options.

Also see drduh/Purse - a fork which integrates with YubiKey instead of using a passphrase.

Details

  1. The "pepper" is an additional string appended to the main passphrase to improve its strength. When the PWDSH_PEPPER option is enabled, a secret value is generated and displayed once, then saved to the respective file.

    The pepper should be written down (can be transcribed with either passphrase.html or passphrase.csv template) and stored in a durable location for backup.

    It is the opinion of the author this feature allows the use of a more memorable, weaker main passphrase without compromising overall security, provided the pepper is backed up separately from the safe.

    Warning The pepper file is not included in backup archives - without the pepper, the safe will not be accessible with the main passphrase alone! This feature is opt-in and the pepper has no effect unless explicitly enabled.

pwd.sh's People

Contributors

comradesmith avatar drduh avatar eliedeloumeau avatar juergenhoetzel avatar mrbalihai avatar ncjones avatar robbydyer 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  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

pwd.sh's Issues

Bash font color changes aren't reseted

Hello,
first of all, I'd like to let you know that I love the idea you came up with in this repository! Keep on developing it!

After I cloned the repo and started using the script, I intentionally produced an error. I like the red error message, but the font color is never reseted, so all the console output was red, until the 'success' message came. Here is the screenshot:
color-bug

I'm using Mac OS X 10.10.4 on a mid-2013 Air. I am not using any other scripts that could possibly override any color settings in the bash.

srm dependency not documented

It required srm to work but that is not part of installation/requirements documentation.

Also what version of srm that must be used because 3.1 in ubuntu do not work with the default options.

tr: Illegal byte sequence

On almost every invocation of ./pwd.sh w someusername 30, I receive a "tr: Illegal byte sequence" response. On the very few invocations that work (one in every 20), my random safe/filename is only 1-2 characters long.

It appears to be a MacOS problem (I'm on 11.6) - and the workaround here appears to work: https://unix.stackexchange.com/questions/45404/why-cant-tr-read-from-dev-urandom-on-osx

LC_CTYPE=C tr -dc "[:lower:]" < /dev/urandom | fold -w8 | head -n1

I don't have any locales in my environment by default, and my zshrc doesn't set any by default - so I think the data pulled from urandom is going haywire.

I'm also not sure if my workaround above is "the" solution, or just a workaround.

Passphrase shows in 'ps' listing

You're passing the gpg passphrase as an argument to gpg, which means it will show in any 'ps' listing while the gpg command is running.

% while :; do ps -ef | grep decrypt | grep -v grep; done
...
jblaine 27709 27704 0 13:24 pts/0 00:00:00 /usr/bin/gpg --decrypt --armor --batch --command-fd 0 --passphrase MyPasswordWasHere pwd.sh.safe

License missing

Hello! Cool project. Could you possibly tack a license on it? It's proprietary otherwise :)

Delete and GPG

I can't delete any password, i get this error: "Write to safe failed" , and every time that i try to run the program, i need to use "sudo" or instead i get an gpg error.

Don't show created password

I think there is actually no need for pwd.sh to show a password just created: it would be safer to do so only if specified and to simply store it otherwise, without sending it to output.

command adds a 'mDoneB' at the end of the copied password

Hi I've been experiencing a strange issue as I get 'mDoneB' these included at the end of the copied password when using:

./pwd.sh r github | cut -f1 -d ' ' | tr -d '\n' | pbcopy

I tried a fresh copy and it worked for the first time but as soon as I wrote over the password. The copy command stops working.

Please do help me if you know any reason for why this would happen.

Thanks.

Add context for password

I have a lot of accounts with the same username, some context like "Twitter" or "Github" for each would help quickly look up a password and differentiate between them in a list.

add "-sel clip" to xclip?

is there any security risk adding "-sel clip" to xcopy?
the password was not getting copied to my clipboard in ubuntu linux, and that did the trick, i left a PR

Use optional env variable for the safe path

This way you could set a different location for the safe file without having to modify the original pwd.sh script e.g: safe=${PWDSH_SAFE:=pwd.sh.safe} on line 10 would mean you could do : export PWDSH_SAFE=/my/dropbox/location/pwd.sh.safe; ./pwd.sh

Final entry can't be removed

Hi,

Thanks for sharing this useful piece of code!

It seems there's a small bug that prevent deletion where there's only one entry remaining.

See:

./pwd.sh w user1 9
./pwd.sh w user2 9
./pwd.sh w user3 9
./pwd.sh r all
# MIcA4iieW user1
# fi+ALzJvT user2
# GZvLkTX4+ user3
./pwd.sh d user1
./pwd.sh d user2
./pwd.sh d user3
# Error: Write to safe failed
./pwd.sh r all
# GZvLkTX4+ user3

I guess that's not a problem for most of users as their safe contains multiple entries, but it is one for new users who want to play with the script and don't understand why the deletion can't work.

Gist backup

What do you think about optional gist backups? You can put pwd safe to a new secret gist repository and attempt to pull/push on read/write. On conflict you just output it and let user resolve manually.

And how do you feel about https://github.com/caodonnell/passman.sh fork?

Spaces aren't allowed in safe passwords

Creating a new safe with a password which contains one or more spaces will cause encryption to fail, and may cause parts of the password to be printed.

Please see my pull request #33

Set umask

Set the umask to the most restrictive possible to avoid other users from reading the tmp file.

pwd.sh.safe can be edited and corrupted

If someone can edit the PGP message in the file, then they can mess with the decryption. I'm envisioning a ransomware type attack where a bad actor gains access, changes a few random characters in the .safe file, and makes the program unable to decrypt the passwords. Kind of like, "I can't see your passwords, but neither can you until you pay me!" Big problem if the keys to someone's entire digital life are stored in that file.

Is there some way to make the .safe file read-only except when pwd.sh is using it?

GPG command not found

When executing the script it looks for gpg in a folder that gpg is not installed in by default (on ubuntu 14.04) It is hardcoded to look in /usr/local/bin/gpg but default it is installed in /usr/bin/gpg. I either have to symlink it to make it work or change the script to look in the correct folder.

Possible solutions, look in more places that it might exist or locate the script with which gpg to make it dynamic.

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.