Name Last Update
doc Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
accountmanager.sh Loading commit data...

accountmanager.sh


NAME

accountmanager.sh − source all functionality into the current shell

General purpose functions:

  • random − create a non blocking stream of random data on stdout
  • rand_printable − create a random string a printable characters

Database management functions:

  • amngrdbinit − initialize the SQLite account database
  • amngrdbdestroy − remove the SQLite account database

Account management functions:

  • amngradd − add an account credential to the database
  • amngrcreate − create a new account credential to the database
  • amngrcrypt − crypt the given data with GnuPG
  • amngrdelete − delete an account
  • amngrgen − generate a encrypted random passphrase
  • amngrgetoldpass − copy previous password of account to X clipboard
  • amngrgetolduser − copy previous username of account to X clipboard
  • amngrgetpass − copy active password of account to X clipboard
  • amngrgetuser − copy active username of account to X clipboard
  • amngrid − write the database id of a given account name to stdout
  • amngrlist − list all accounts
  • amngrrename − rename an account
  • amngrsearch − pattern search accounts

SYNOPSIS

source ${PATH}/accountmanager.sh

random

rand_printable [len]

amngrdbinit [dbfile]

amngrdbdestroy [dbfile]

amngradd -u username -p password [-d description] [-D dbfile] [-r recipient] account

amngrcreate -u username [-d description] [-D dbfile] [-r recipient] account

amngrcrypt [-r recipient] password

amngrdelete account

amngrgen [-r recipient] [len]

amngrgetoldpass account

amngrgetolduser account

amngrgetpass account

amngrgetuser account

amngrid account

amngrlist [-s separator]

amngrrename old_account new_account

amngrsearch [-s separator] pattern

DESCRIPTION

This file can either be source into the current shell or used as a standalone shell script via the provided symlinks. When used as standalone script it will detect the function to call by the content of $0.

All account as well as all username arguments used below are limited to 128 characters. The account argument is always a unique string identifier for the account to manage. The username argument is the username part of a credential which is a (username, password) pair.

random

Takes no arguments and connect a non blocking random source to stdout.

rand_printable [len]

Uses random to write a string of random printable characters to stdout. All control characters ASCII-0 to ASCII-37 as well as ASCII-177 to 255, single and double quotes are filtered. The single and double quotes are filtered to prevent problems when they are used as string separators after shell expansion as in the SQL here documents used to communicate with the SQLite database.
The optional len argument specifies the string length to be written and defaults to 512.

amngrdbinit [dbfile]

Create the SQLite database file. If the optional dbfile argument is given it specifies the fill path to the file to use, else the value of $AMNGRDB environment variable is used.

amngrdbdestroy [dbfile]

Deletes the SQLite database file. If the optional dbfile argument is given it specifies the fill path to the file to use, else the value of $AMNGRDB environment variable is used.

amngradd -u username -p password [-d description] [-D dbfile] [-r recipient] account

Adds an account credential and marks it as active. If the account already exist, the credential (username and password) is added to that account and the previously added credential is marked as old. If there was another even older credential that was already marked as old this will be marked as inactive and this becomes inaccessible with this tools (except for amngrdelete).
The necessary option -u specifies the username to be stored with this credential pair.
The also necessary option -p specifies the password to be stored and the length of password is not limited at all.
With option -d one can add a description to the account entry. One can specify the dbfile with the option -D if that option is not given the $AMNGRDB environment variable is used.

amngrcreate -u username [-d description] [-D dbfile] [-r recipient] account

This will create a password with amngrgen and use that to add an credential via amngradd. (See there for options description) The added password will be copied to the X clipboard with amngrgetpass for further use.

amngrcrypt [-r recipient] password

Crypt the given plain text password with GnuPG and write it to stdout. The option -r specifies the recipient to use with the call to gpg. If it is not given the value of the $AMNGRID environment variable is used.

amngrdelete account

Remove the account and all credential associated to it.

amngrgen [-r receipient] [len]

Generate a password with rand_printable and encrypt it via amngrcrypt. By default the password will be 10 characters long. That can be modified by the optional len argument.

amngrgetoldpass account

Read and decrypt the password associated with account that is flagged as old and store it into the X clipboard.

amngrgetolduser account

Read and decrypt the username associated with account that is flagged as old and store it into the X clipboard.

amngrgetpass account

Read and decrypt the password associated with account that is flagged as active and store it into the X clipboard.

amngrgetuser account

Read and decrypt the username associated with account that is flagged as active and store it into the X clipboard.

amngrid account

(This is primarily for internal use.) Get the database id associated to the given account argument.

amngrlist [-s separator]

List all accounts currently stored within the database the output will contain the name of the account, the username and the description delimited by a separator string that can be specified with the -s option. If the option is omitted the separator is " => ". Each row is one account.

amngrrename old_account new_account

Rename the account specified by old_account to new_account.

amngrsearch [-s separator] pattern

List accounts where pattern exists in either the account name, the username or the account description. The output is like the one described with amngrlist.

OPTIONS

The options are consistent over all sub commands. However not all sub commands use all options and some sub commands take arguments that other get per option. (See DESCRIPTION)

  • -u The login username of the credential for the account.
  • -p The plain text password of the credential for the account.
  • -d The description for the account.
  • -D Select the database file to use instead of the one defined in the $AMNGRDB environment variable.
  • -r Select a recipient id for GnuPG encryption to use instead of the one defined in the $AMNGRID environment variable.
  • -s The column separator for the amngrlist and amngrsearchcommands.

ENVIRONMENT

AMNGRDB

The default SQLite database file to use. This will be created with amngrdbinit as long as the path to that file exists. This can be overruled with the -D command line option.

AMNGRID

The GnuPG recipient id to encrypt against. You should use one where you have both public and private key. Failure to do so will result in not decipherable data. This can be overruled with the -r command line option.

AMNGRPWLEN

The password length to be used when generating new passwords.

DEPENDENCIES

A set of POSIX compliant shell utilities including a POSIX compliant shell as well are needed to run this script.

The functions within this script expect that all the needed tools can be found by the shell, usually that means that the current $PATH environment variable is set accordingly or that the tools are a shell internal.

The existence of a reliable non blocking random source. By default this scripts use $(cat /dev/urandom) which can be changed by replacing the alias random with something useful for your system.

For data storage Sqlite >= 3.6.19 is required. The version requirement comes from the use of foreign key constraints.

To store the data within the X clipboard the xclip is needed.

The tools used are

  • awk
  • basename
  • cat
  • dnsdomainname
  • echo
  • getopts
  • gpg
  • head
  • printf
  • rm
  • shift
  • SQLite3 (>= 3.6.19 for foreign key constraints)
  • test and [
  • tr
  • xclip

SEE ALSO

gpg2(1), gpg-agent(1)

BUGS

No known bugs.

AUTHOR

Georg Hopp (georg@steffers.org.in)

COPYRIGHT

Copyright © 2017 Georg Hopp License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.