Register Agents

Two requests are needed to register an agent using the API:

We have prepared a few scripts in different programming languages to help with the task of registering an agent with the API:

Basically, the scripts perform the following steps:

Step 1: Add the agent to the manager.

# curl -u foo:bar -X POST -d 'name=NewAgent&ip=' "http://localhost:55000/agents"

Step 2: Get the agent key.

# curl -u foo:bar -X GET "http://localhost:55000/agents/001/key"

Step 3: Copy the key to the agent.

# /var/ossec/bin/manage_agents -i MDAxIE5ld0FnZW50IDEwLjAuMC44IDM0MGQ1NjNkODQyNjcxMWIyYzUzZTE1MGIzYjEyYWVlMTU1ODgxMzVhNDE3MWQ1Y2IzZDY4M2Y0YjA0ZWVjYzM=


If you paste the command directly into the terminal, the agent key will be saved in the bash history. Use manage_agents without arguments or from a script.

Step 4: Restart the agent.

# /var/ossec/bin/ossec-control restart