ezl
is a CLI tool, written in Go that makes it easy to manage users and groups in systems using LDAP to handle user management and authentication.
ezl [command] ...
Commands:
user - Manage users
group - Manage groups
The user command can be used to create, remove and modify users.
Usage: ezl user <command> ...
Commands:
add - Add a new user
remove - Remove an existing user
change - Change the attributes of an existing user
set_pwd - Set the password for an existing user
The user add
command can be used to create new users. If the uid
parameter it's omitted, it will be chosen automatically: ezl
will find the user with highest uid in the system, and will choose the next number. It will also automatically create a user group with the same name as username
.
Usage: ezl user add <username> [-name name] [-surname surname] [-pwd password] [-uid user_id] [-mail email]
Examples:
# Since uid is omitted
ezl add user john.doe -name John -surname Doe
The user remove
command will remove an existing user from the system.
Usage: ezl user remove <username>
Examples:
ezl user remove john.doe
The user change
command can be used to change user attributes after creation.
Usage: ezl user change <username> [-name name] [-surname surname] [-shell loginShell] [-mail mail] [-home homeDirectory]
Examples:
ezl user change john.doe -name John2 -surname Doe2 -shell /bin/sh -mail john.doe2@mail.com -home "/newhome/joh.doe.2"
The user set_pwd
command can be used to change the password for a user. It will interactively prompt (no echo) for the password after being invoked.
Usage: ezl user set_pwd <username>
Examples:
ezl user set_pwd john.doe
The group
command can be used to add and remove groups, as well as adding and removing user from groups.
Usage: ezl group [command] ...
Commands:
add - Add a new group
remove - Remove an existing group
add_user - Add a user to an existing group
remove_user - Remove user from an existing group
The group add
command will create a new group in the system. If gid
is omitted, ezl
will find the highest gid in the system, and automatically choose the next number for the group.
Usage: ezl group add <groupname> [-gid group_id]
Examples:
# Add group with automatic gid
ezl group add mygroup
# Add group with a specific gid
ezl group add mygroup -gid 9999
group remove
will remove a group from the sytem.
Usage: ezl group remove <groupname>
Examples:
ezl group remove mygroup
The command group add_ser
can be used to add an existing user to a group.
Usage: ezl group add_user <groupname> <user_name>
Examples
ezl group add_user mygroup john.doe
The command group add_ser
can be used to remove an existing user to a group.
Usage: ezl group remove_user <groupname> <user_name>
Examples
ezl group remove_user mygroup john.doe
ezl
will look for the file /etc/ezl/config.json
to retrieve important configuration parameters. The file needs to have the following fields:
- ldapUri - (Mandatory) The URI that will be used to connect to LDAP
- baseDN - (Mandatory) The root DN that will be used for searches and modifications
- bindDN - (Mandatory) The DN that will be used for LDAP binding
- userHomePath - The default home path that will be set for new users (Default: /home/). This directory won't be created, it will only be set in the user entry.
- loginShell - The default home shell that will set for new users (Default: /bin/bash)
Example configuration:
{
"baseDN": "dc=my,dc=ldapserver,dc=com",
"bindDN": "cn=Manager,dc=my,dc=ldapserver,dc=com",
"userHomePath": "/home/",
"loginShell": "/bin/bash",
"ldapUri": "ldap://localhost:389"
}
The CLI tool can be built by running
go build ./ezl/cmd