Control and manage servers and users using API
How to manage and update servers and users using the API in Ezeelogin?
Overview: This guide provides step-by-step instructions on how to control Ezeelogin functions and manage servers and users using the API in Ezeelogin.
Step 1: How to enable or disable API function?
Log in to the Ezeelogin GUI and navigate to Settings -> API. Enter the new API secret, confirm new API secret, and enable/disable the API option to allow or block the API scripts from working. Save the changes using the authorization password (password of the currently logged-in user).

php /usr/local/ezlogin/ezwapi.php -help
Usage:
ezwapi.php -help <action>
action : API action (list_servers/add_server/update_server/remove_server/reset_fingerprint/get_password/setup_sshusers/add_user_server_acl/suspend_user/unsuspend_user/force_user_password_change/reset_user_password/reset_user_2fa/set_user_expiry)
Step 2: How to enable or disable the user update function?
Log in to the Ezeelogin GUI and navigate to Settings -> API -> Enable/Disable User API to enable or disable user update function with API script.

How to execute the API script for the user update function?
Log in to the server where you have the ezwapi.php script.
Example of enabled user API:
php /usr/local/ezlogin/ezwapi.php suspend_user -api_url http://localhost -secret 12345 -user tony
200: {"status":"success","data":"Success"}
Example of disabled user API:
php /usr/local/ezlogin/ezwapi.php suspend_user -api_url http://localhost -secret 12345 -user tony
200: {"status":"error","data":"User API is disabled"}
Step 3: How to enable or disable the access control function to grant users access privileges to servers?
Log in to the Ezeelogin GUI and navigate to Settings -> API -> Enable/Disable Access Control API to enable or disable access control update function with API script.

How to execute the API script for the access control function?
Log in to the server where you have the ezwapi.php script.
php /usr/local/ezlogin/ezwapi.php -help add_user_server_acl
Usage:
ezwapi.php add_user_server_acl -api_url <API URL> -secret <API secret> -user <username> -server <hostname> [-defer]
-api_url : The API URL
-secret : The API secret configured in web panel settings
-user : The username
-server : The server host name
-defer : Defer the ACL addition if user doesn't already exist (optional)
Example of enabled access control API:
php /usr/local/ezlogin/ezwapi.php add_user_server_acl -api_url http://localhost -secret 12345 -user tony -server database.serv
er
200: {"status":"success","data":"Saved","extra":{"25":{"3":1}}}
Example of disabled access control API:
php /usr/local/ezlogin/ezwapi.php add_user_server_acl -api_url http://localhost -secret 12345 -user tony -server database.serv
er
200: {"status":"error","data":"Access Control API is disabled"}
Step 4: How to enable or disable the password reset function?
Log in to the Ezeelogin GUI and navigate to Settings -> API -> Enable/Disable User API and Password Reset API to enable or disable password reset function with API script.

How to execute the API script for the access control function?
Log in to the server where you have the ezwapi.php script.
Example of enabled User API and Password Reset API:
php /usr/local/ezlogin/ezwapi.php reset_user_password -api_url http://localhost -secret 12345 -user tony
200: {"status":"success","data":"8rV2N5EGU9"}
Note: Log in to the GUI using the temporary password; you will be prompted to reset the user's password.
Example of disabled User API:
php /usr/local/ezlogin/ezwapi.php reset_user_password -api_url http://localhost -secret 12345 -user tony
200: {"status":"error","data":"User API is disabled"}
Example of disabled Password Reset API:
php /usr/local/ezlogin/ezwapi.php reset_user_password -api_url http://localhost -secret 12345 -user tony
200: {"status":"error","data":"User password reset via API is disabled"}
Step 5: How to enable or disable the server update function using the API?
Log in to the Ezeelogin GUI and navigate to Settings -> API -> Enable/Disable Server API to enable or disable server update function with API script.

How to execute the API script for the server update functions?
Log in to the server where you have the ezwapi.php script.
Example of enabled Server API:
php /usr/local/ezlogin/ezwapi.php list_servers -api_url http://localhost -secret 12345
200: {"status":"success","extra":[{"id":"3","name":"database.server"}]}
Example of disabled Server API:
php /usr/local/ezlogin/ezwapi.php list_servers -api_url http://localhost -secret 12345
200: {"status":"error","data":"Server API is disabled"}
Step 5: How to enable or disable the API server group for controlling which server groups can be updated via the API?

How to execute the API script for the server group functions?
Log in to the server where you have the ezwapi.php script.
Example of enabled Server API and API Server Groups:
php /usr/local/ezlogin/ezwapi.php update_server -api_url http://localhost -secret 12345 -name database.server -group 'production servers' -ssh_port 22 -description db_server
200: {"status":"success","data":"Saved"}
Example of disabled Server API:
php /usr/local/ezlogin/ezwapi.php update_server -api_url http://localhost -secret 12345 -name database.server -group 'production servers' -ssh_port 22 -description db_server
200: {"status":"error","data":"Server API is disabled"}
Example of disabled API Server Groups:
php /usr/local/ezlogin/ezwapi.php update_server -api_url http://localhost -secret 12345 -name database.server -group 'production servers' -ssh_port 22 -description db_server
200: {"status":"error","data":"API server group denied"}
This feature is available from Ezeelogin version 7.46.0. Refer article to upgrade Ezeelogin to the latest version.
Related Articles:
Add / update / delete servers through ezeelogin API
Managing users in Ezeelogin via API