Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/taraspos/cruser
- Owner: taraspos
- Created: 2016-12-11T20:46:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-26T22:16:07.000Z (almost 8 years ago)
- Last Synced: 2024-06-21T07:46:09.125Z (5 months ago)
- Topics: linux, ssh-key, user-creation, user-management
- Language: Go
- Size: 889 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)