Package: unix-accounts
Unix-accountsUnix-accountsmakes it possible to store accounts globally in one common
database, instead of manually keeping them synchronized locally on each
computers.If having a shared network filesystem as example, the accounts (name, id) needs
to be synchronized between the computers. This does not scale well since the
effort to administrate accounts increases with the amount of computers times
the amount of accounts.One solution is to to use ldap. However, the additional complexity to configure
the system and managing the accounts might not always balance up the gain. The
goal with this project has been to keep the account administration and system
configuration as simple and user-friendly as possible.Unix-accountsuses a sqlite-database* as storage backend and provides a
commandline interface to manage the accounts. It implements the nss api forpasswd,group,shadow. Simple and minimal, nothing more, nothing less.
The nss api is exposed over http(s) and is intended to be used with pluginhttps://github.com/1nfiniteloop/nss-http.*The storage backend can be switched to another sql-database, it is portable
and easy to replace since sqlalchemy is used.Note:This database is not intended to replace the regular account mechanism with/etc/{passwd,shadow,group}. It extends the database lookups by using the name
service switch (nss) api. See more @http://man7.org/linux/man-pages/man5/nsswitch.conf.5.htmlandhttps://www.gnu.org/software/libc/manual/html_node/NSS-Basics.html.TheName Service Switchperform lookups only, example ongetent {group,passwd,shadow}. This means that changing account data is not
part of the nss api. Tools for changing accounts such aspasswd,useradd,groupaddis implemented to manipulate/etc/{group,passwd,shadow}directly.
Account administration is therefore done on the same computer as theunix-accountsserver is on, using its provided commandline interface.UsageInstallUse docker-container (preferred), which starts the server as entrypoint:docker run -it \
  --name unix-accounts \
  --volume=unix-accounts:/var/opt/unix-accounts \
  --network=lan \
  1nfiniteloop/unix-accounts:latestOr install with pip:pip install unix-accountsServerIf installed with pip:Data is stored in/var/opt/unix-accounts. Create
this folder and give permissions accordingly, or provide alternative path with:--db=<path-to-sqlite-db> --token-db=<path-to-token-db>on invocation.Create a new token to give api access to passwords:unix-accounts-server --generate-tokenStart server with:unix-accounts-serverAccounts can now be accessed with:curl -i \
    -H "Authorization: bearer MOE66ljNwXXF8R81OqGrDfbWmuZUjmlarDvdZt4X1dQ" \
    http://localhost:8025/api/{user,group,password}?name=fooCommandline interfaceIf installed with pip, access cli with:unix-accountsIf using docker-container, access cli with:docker exec -it unix-accounts unix-accountsGeneral usage:unix-accounts {group,user,group-member,password}Use flag--helpto see all options.The commandline interface enters interactive mode if used without arguments.
This is more efficient since application loads the database once at start,
instead of on each command invocation.Example: Add userunix-accounts# user add foo --uid 10000
+-----------+-------+-------+-------+-----------+-----------+------------------+
| User name | Id    | Group | Gecos | Home dir  | Shell     | Group membership |
+-----------+-------+-------+-------+-----------+-----------+------------------+
| foo       | 10000 | foo   |       | /home/foo | /bin/bash |                  |
+-----------+-------+-------+-------+-----------+-----------+------------------+Example: add user to a groupunix-accounts# group-member add foo developer
+------------+-------+-----------------+
| Group name | Id    | User membership |
+------------+-------+-----------------+
| developer  | 10001 | foo             |
+------------+-------+-----------------+Example: set new passwordunix-accounts# password foo
New password:DevelopRun locallyChange to directoryunix-accounts/src.Run unittests withpython3 -m unittest discover -s . -p "*_test.py".Start server withpython3 -m unix_accounts.bin.server [flags].Start interactive commandline interface withpython3 -m unix_accounts.bin.cli [flags].Build packageMake sure package build is available, or install withpython3 -m pip install buildBuild source and dist packages with:python3 -m build --wheel --sdistThe built wheel distribution is located indist/, install withpip install dist/unix_accounts-1.0.0-py3-none-any.whlBuild docker containerNote: The docker build uses the local built python package.docker build --tag 1nfiniteloop/unix-accounts:latest .