Assign command guard groups for users or user groups
How to assign command guard groups for users or user groups from the command line interface (CLI)?
Create and assign commands to command guard groups using the below article.
How to view the database and prefix name using by Ezeelogin?
1. Run the below command to find the database and prefix name.
[email protected] ~]# cat /usr/local/etc/ezlogin/ez.conf | grep -i 'db_name\|db_prefix'
Refer below example output of the above command.
db_name ezlogin_gueqvf
db_prefix iprspn_
2. Run the below single command to view the command guard ID and user group ID. Replace db_name and db_prefix from the above output.
[email protected] ~]# mysql -u root -e "use db_name ; select * from db_prefix_commandgroups;" -p
[email protected] ~]# mysql -u root -e "use db_name ; select * from db_prefix_usergroups;" -p
Refer below example output of the above commands to view the command guard group ID and user group ID.
- [email protected] ~]# mysql -u root -e "use ezlogin_gueqvf ; select id,name from iprspn_commandgroups ; " -p
Enter password:
+----+---------+
| id | name |
+----+---------+
| 1 | default |
+----+---------+
- [email protected] ~]# mysql -u root -e "use ezlogin_gueqvf ; select id,name from iprspn_usergroups ; " -p
Enter password:
+----+--------+
| id | name |
+----+--------+
| 1 | Admins |
| 2 | Dummy |
+----+--------+
Refer below screenshots of the command guard group from Ezeelogin GUI.
Refer below screenshots of the user group from Ezeelogin GUI.
How to assign a command guard group for a user group from CLI?
- Run the below command to assign the command guard group to the user group with Disallow (allow all command that does not match the command group). Below command will assign the command guard group default to user group Dummy. Replace command guard group ID and user group ID.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Disallow' WHERE usergroup_id=2"
- Run the below command to assign the command guard group to the user group with Allow (allow only input matching the command group). Below command will assign the command guard group default to user group Dummy. Replace command guard group ID and user group ID.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Allow' WHERE usergroup_id=2"
How to disable command guard group for a user group from CLI?
- Run the below command to disable the command guard group for a user group. Replace user group ID
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=0 WHERE usergroup_id=2"
How to assign a command guard group for multiple user groups from CLI?
- Run the below command to assign the command guard group to the multiple user groups with Disallow. Replace command guard group ID and user group ID. Add multiple user groups separated with OR to assign it to all user groups.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Disallow' WHERE usergroup_id=1 OR usergroup_id=2"
- Run the below command to assign the command guard group to the multiple user groups with Allow. Replace command guard group ID and user group ID. Add multiple user groups separated with OR to assign it to all user groups.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Allow' WHERE usergroup_id=1 OR usergroup_id=2"
How to disable command guard group for multiple user groups from CLI?
- Run the below command to disable the command guard group for the multiple user groups. Replace user group ID.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=0 WHERE usergroup_id=1 OR usergroup_id=2"
How to view the command guard group ID and user ID from CLI?
Run the below single command to view the command guard group ID and user ID. Replace db_name and db_name.
[email protected] ~]# mysql -u root -e "use db_name ; select id,username from db_prefix_commandgroups;" -p
[email protected] ~]# mysql -u root -e "use db_name ; select id,username from db_prefix_users;" -p
Refer below example output of the above command.
- [email protected] ~]# mysql -u root -e "use ezlogin_gueqvf ; select id,username from iprspn_commandgroups;" -p
Enter password:
+----+---------+
| id | name |
+----+---------+
| 1 | default |
+----+---------+
- [email protected] ~]# mysql -u root -e "use ezlogin_gueqvf ; select id,username from iprspn_users;" -p
Enter password:
+----+----------+
| id | username |
+----+----------+
| 1 | ezadmin |
| 2 | alex |
| 3 | tony |
| 4 | john |
+----+----------+
How to assign a command guard group for multiple users from CLI?
- Run the below command to assign the command guard group to multiple users with Allow. Replace command guard group ID and usernames. Add multiple usernames separated with OR to assign them to all user groups.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Allow' WHERE username='tony' OR username='john'"
- Run the below command to assign the command guard group to multiple users with Disallow. Replace command guard group ID and usernames. Add multiple usernames separated with OR to assign them to all user groups.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Disallow' WHERE username='tony' OR username='john'"
How to disable command guard group for multiple users from CLI?
- Run the below command to disable the command guard group for multiple users. Replace usernames.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=0 WHERE username='tony' OR username='john'"
How to assign a command guard group for a single user from CLI?
- Run the below command to assign the command guard group to a single user with Allow. Replace command guard group ID and username.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Allow' WHERE username='alex'"
- Run the below command to assign the command guard group to a single user with Disallow. Replace command guard group ID and username.
[email protected] ~]# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users SET commandgroup_id=1,command_guard_type='Disallow' WHERE username='alex'"