Skip to content

Instantly share code, notes, and snippets.

@bleything
Created February 9, 2011 21:48
Show Gist options
  • Select an option

  • Save bleything/819375 to your computer and use it in GitHub Desktop.

Select an option

Save bleything/819375 to your computer and use it in GitHub Desktop.

Revisions

  1. bleything revised this gist Feb 22, 2011. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion passwords.rake
    Original file line number Diff line number Diff line change
    @@ -42,12 +42,18 @@ namespace :passwords do
    # and encrypt the passwords.txt
    cmd << "passwords.txt"

    exec cmd.join(' ')
    exec *cmd
    end

    desc "Decrypts passwords.gpg and writes it to passwords.txt"
    task :decrypt do
    exec "gpg --armor --decrypt --yes --output passwords.txt passwords.pgp"
    end

    desc "Uses `pwgen` to generate a few good passwords"
    task :generate, [:length] do |_, args|
    length = args.length || 15
    exec "pwgen --numerals --capitalize --symbols #{length}"
    end

    end
  2. bleything revised this gist Feb 19, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion passwords.rake
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ namespace :passwords do

    desc "Decrypts passwords.gpg and writes it to passwords.txt"
    task :decrypt do
    exec "gpg --armor --decrypt --output passwords.txt passwords.pgp"
    exec "gpg --armor --decrypt --yes --output passwords.txt passwords.pgp"
    end

    end
  3. bleything revised this gist Feb 9, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions passwords.rake
    Original file line number Diff line number Diff line change
    @@ -29,9 +29,9 @@ namespace :passwords do

    desc "Encrypts the current passwords.txt file"
    task :encrypt do
    # ascii armor, encrypt, sign, overwrite passwords.pgp
    # ascii armor, encrypt, sign, overwrite passwords.pgp, always trust public keys
    cmd = %w[
    gpg --armor --encrypt --sign --output passwords.pgp --yes
    gpg --armor --encrypt --sign --output passwords.pgp --yes --trust-model always
    ]

    # add -r <email> for each user
  4. bleything created this gist Feb 9, 2011.
    53 changes: 53 additions & 0 deletions passwords.rake
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    ########################################################################
    ### Rakefile for encrypted passwords
    ########################################################################
    #
    # Here's a little Rakefile to manage your encrypted password file! It's
    # really easy to use:
    #
    # 1) put the email addresses of the keys you want in AUTHORIZED_USERS
    # 2) create a passwords.txt (and ignore it in your SCM)
    # 3) run `rake passwords:encrypt`
    # 4) check in passwords.pgp
    #
    # To decrypt, just run `rake passwords:decrypt`
    #
    ########################################################################
    #
    # Ben Bleything wrote this, and would love it if you gave him lots of
    # money. You can email him at [email protected] for wire transfer info.
    #
    # That said, there's nothing special in here, so I'm placing it in the
    # public domain.
    #

    AUTHORIZED_USERS = %w[
    [email protected]
    ]

    namespace :passwords do

    desc "Encrypts the current passwords.txt file"
    task :encrypt do
    # ascii armor, encrypt, sign, overwrite passwords.pgp
    cmd = %w[
    gpg --armor --encrypt --sign --output passwords.pgp --yes
    ]

    # add -r <email> for each user
    AUTHORIZED_USERS.each do |user|
    cmd << "-r #{user}"
    end

    # and encrypt the passwords.txt
    cmd << "passwords.txt"

    exec cmd.join(' ')
    end

    desc "Decrypts passwords.gpg and writes it to passwords.txt"
    task :decrypt do
    exec "gpg --armor --decrypt --output passwords.txt passwords.pgp"
    end

    end