Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/taraspos/cruser

Create Linux users from list of SSH keys.
https://github.com/taraspos/cruser

linux ssh-key user-creation user-management

Last synced: 23 days ago
JSON representation

Create Linux users from list of SSH keys.

Awesome Lists containing this project

README

        

# [CR]eate [USER] -> cruser

Tool to create users on Linux system.

Mechanism of users creation are inspired by Google Cloud, when username are automatically taken from SSH-key(and email after).

List of users are need to be provided in the **authorized_keys** file format.

## Requirements
Tool don't use any external libraries, but relies on some default(in most Linux distros) CLI tools:
* `id` - used to check, if user exist in the system, get user's *gid* and *uid*
* `useradd` - used for user creation
* `visudo` - used for validation of sudoers lines

## Example:
* File *users*:
```
ssh-rsa aaaaaaaaaaaaaaaaaaaaaa [email protected]
ssh-rsa bbbbbbbbbbbbbbbbbbbbbb [email protected]
ssh-rsa cccccccccccccccccccccc [email protected]
ssh-rsa cccccccccccccccccccccc [email protected]
```

* Result of running command `cruser -file users` will be:
* Created users **test** and **hello**
* Sudoers lines are generated and validated with **visudo**
* Line `test ALL=(ALL) NOPASSWD:ALL` added to the file */etc/sudoers.d/test*
* Line `hello ALL=(ALL) NOPASSWD:ALL` added to the file */etc/sudoers.d/hello*
* Provided SSH keys are added to the */home/test/.ssh/authorized_keys* and */home/hello/.ssh/authorized_keys*
* Duplicated lines are skipped
* **[email protected]** and **[email protected]** are added as comment entry in the */etc/password* file

## Build:
```
make build
```

## Running demo:
```
make demo
```

## Missing features:
* Adding SSH-keys for existing users. Currently only newly created users supported
* Reading SSH-keys list form remote location(S3, github, etc)
* More flexible Sudoers configuration(only NOPASSWD:ALL are supported now)