Add / update / delete servers through ezeelogin API

How to add/delete/update servers using ezeelogin API

 

Login to Ezeelogin Gui > Open Settings >  API

 

 Add the details of API configurations and Make sure API is enabled in API settings for the API script to work.
 
  
 
 
 

An API script is provided for automating server add/edit/delete tasks in Ezeelogin. With the help of this script, you can integrate Ezeelogin with any 3rd party application managing your clients/customers. Also, make sure to  enable API .

 

The API script can be executed as:

 

[email protected]:~# php /usr/local/ezlogin/ezwapi.php [params...]

For  Help 

[email protected]:~# php /usr/local/ezlogin/ezwapi.php -help

Usage:

 

ezwapi.php -help <action>

action : API action (add_server/update_server/remove_server)

 

ADD SERVER 

 

[email protected]:~# php /usr/local/ezlogin/ezwapi.php -help add_server

Usage:

 

ezwapi.php add_server -api_url <API URL> -secret <API secret> -name <hostname> -password <password> -ip_address <IP address> -group <group> [-ssh_port <port>] [-ssh_user <username>] [-keep_password <Y/N/S>]

[-enable_ssh <Y/N/H>] [-cp <control panel>]

 

-api_url : The API URL

-secret : The API secret configured in web panel settings

-name : The server host name

-password : The server password

-ssh_key : The SSH private key file (optional)

-passphrase : The SSH key pass phrase (optional)

-ip_address : The server IP address

-ssh_port : The server SSH port (optional, use default if unspecified)

-ssh_user : The server SSH user (optional, use default if unspecified)

-switch_user : Switch to this user after login as SSH user (optional)

-switch_pass : Password for switch user (optional)

-switch_sudo : Y or N or E to escalate privilege with 'sudo su' or 'enable' (for Cisco devices) (optional, default: N = disabled)

-prompt1 : Unique string in shell prompt of SSH user (optional)

-prompt2 : Unique string in password prompt for su or sudo (optional, default: Password:)

-prompt3 : Unique string in shell prompt of root user (optional, required for sudo)

-group : The server group name

-keep_password : Y (keep given password), N (automatic) or S (keep server password as such - no verification) (optional, default: Y)

-enable_ssh : Y, N or H to enable/disable/via Host Node (optional, default: N)

-ishn : Y or N to make this a Host Node or not (optional, default: N)

-onhost : The name of Host Node (optional, default: N)

-cp : The control panel name (optional, use default if unspecified)

-dc : The datacenter name (optional, use default if unspecified)

-rc_host : The remote console host (optional)

-rc_user : The remote console user (optional)

-rc_pass : The remote console password (optional)

 

 Add Server  Example: 

[email protected]:~# php /usr/local/ezlogin/ezwapi.php add_server -api_url http://10.11.1.137/ezlogin -secret  [email protected]#$!   -name test.noc.com -password test123 -ip_address 10.11.1.138 -group test

Add Server Example where the ssh user is non root

[email protected]:~# /usr/local/ezlogin/ezwapi.php add_server -api_url http://192.168.56.106/ezlogin -secret 123#$4  -ssh_user ezeelogin -group linux -ssh_key /root/.ssh/id_rsa -name skunk.ezno.con -ip_address 192.168.56.143 -prompt1 ']$ ' -prompt2 'ssword:' -enable_ssh Y 

 How will i find the prompts for the ssh_user?

The easiest way to find the prompt1 is to ssh as  the user directly into the server. The prompts may vary depending on the remote OS in use. For example, when the remote machines is Centos 5.6,7, the login prompts when a non root user logs in is 

[[email protected] ~]$ cd /home

Here the unique string that remains permanent are "]$ ". Note that there are 3 characters including space.

For Ubuntu 14,16 ,18

[email protected]:~$ cd /home

Here the unique string that remains permanent are the characters "cd:".

To find prompt2, simply run su - as a non root user.

[[email protected] home]$ su -

Password:

The prompt 2  or the unique string that remains permanent would be  "rd:" 

The prompt 3 would be how the root prompt looks like 

[[email protected] home]#

Above the unique characters that is permanent are  "[email protected]" or "[email protected]" etc.

 

UPDATE SERVER 

[email protected]:~# php /usr/local/ezlogin/ezwapi.php -help update_server

Usage:

 

ezwapi.php update_server -api_url <API URL> -secret <API secret> -name <hostname> [-newname <new hostname>] [-password <password>] [-ip_address <IP address>] [-ssh_port <port>] [-ssh_user <username>]

[-group <group>] [-keep_password <Y/N/S>] [-enable_ssh <Y/N>] [-cp <control panel>]

 

-api_url : The API URL

-secret : The API secret configured in web panel settings

-name : The server host name

-newname : The new host name (optional)

-password : The server password (optional)

-ssh_key : The SSH private key file (optional)

-passphrase : The SSH key pass phrase (optional)

-ip_address : The server IP address (optional)

-ssh_port : The server SSH port (optional)

-ssh_user : The server SSH user (optional)

-switch_user : Switch to this user after login as SSH user (optional)

-switch_pass : Password for switch user (optional)

-switch_sudo : Y or N or E to escalate privilege with 'sudo su' or 'enable' (for Cisco devices) (optional, default: N = disabled)

-prompt1 : Unique string in shell prompt of SSH user (optional)

-prompt2 : Unique string in password prompt for su or sudo (optional)

-prompt3 : Unique string in shell prompt of root user (optional, required for sudo)

-group : The server group name

-keep_password : Y (keep given password), N (automatic) or S (keep server password as such - no verification) (optional)

-enable_ssh : Y, N or H to enable/disable/via Host Node (optional)

-ishn : Y or N to make this a Host Node or not (optional)

-onhost : The name of Host Node (optional)

-cp : The control panel name (optional)

-dc : The datacenter name (optional)

-rc_host : The remote console host (optional)

-rc_user : The remote console user (optional)

-rc_pass : The remote console password (optional)

 

 Example - UPDATE SERVER

[email protected]:~#   php /usr/local/ezlogin/ezwapi.php update_server -api_url http://10.11.1.137/ezlogin -secret [email protected]#$! -name ez.test.com -password test123 -ip_address 10.11.1.138 -group test

DELETE SERVER

[email protected]:~# php /usr/local/ezlogin/ezwapi.php -help remove_server

Usage:

 

ezwapi.php remove_server -api_url <API URL> -secret <API secret> -name <hostname>

 

-api_url : The API URL

-secret : The API secret configured in web panel settings

-name : The server host name

 

Example - Delete Server

[email protected]:~# php /usr/local/ezlogin/ezwapi.php  remove_server -api_url http://10.11.1.137/ezlogin -secret  [email protected]#$! -name ez.test.com 

 

  

   Make sure API is enabled in API settings for the API script to work.
 
If you need to execute the API script from a server other than the Ezeelogin installed server(jump server), copy /usr/local/ezlogin/ezwapi.php and /usr/local/ezlogin/apilib file to the server which you want to execute. PHP should be installed on the server.
0 (0)
Article Rating (No Votes)
Rate this article
    Attached Files
    There are no attachments for this article.
    Related Articles RSS Feed
    Webportals unavailable for user
    Viewed 2753 times since Fri, Dec 8, 2017
    How to increase the speed of execution in parallel shell?
    Viewed 1236 times since Fri, Mar 30, 2018
    Configure ssh timeout in ssh gateway
    Viewed 2463 times since Fri, Dec 1, 2017
    Add a server using ssh key pair in ezeelogin
    Viewed 534 times since Fri, Mar 22, 2019
    Add custom message or MOTD ( Message of the day) on the jump server| How to add the custom text message on login ?
    Viewed 384 times since Mon, May 27, 2019
    Set SSH User Expiry
    Viewed 1139 times since Thu, Sep 20, 2018
    Error: ENOENT while trying to access RDP after upgrading ezeelogin
    Viewed 648 times since Wed, Jun 6, 2018
    record rdp session
    Viewed 997 times since Thu, Dec 6, 2018
    Parallel Shell - How to use it?
    Viewed 1617 times since Thu, Nov 23, 2017
    How to copy or delete a file in jump server users home directory?
    Viewed 1297 times since Wed, Apr 18, 2018