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.
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 uiduseradd
- used for user creationvisudo
- used for validation of sudoers lines
- 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
make build
make demo
- 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)