Unable to authenticate, please check your API credentials (RestApiClient.php:182)

  • on a few of Icinga2 Director i never had the problem with Kickstart API ,but after several installation i got stucked with this error


    in previous installation


    Master -> Windows Client agent installed then installed Director , never saw Erorr 182 as below.




    Unable to authenticate, please check your API credentials (RestApiClient.php:182)

    New installation without Master Setup (icinga2 node wizard /no )
    • Icinga2 new installation
    • Master Zone added
    • icinga2 api setup
    • comment out /* Include conf.d in icinga2.conf */


    What is the diffenrent between /etc/icinga2/conf.d/api-users.conf and /etc/icinga2/features-available/api.conf ?


    I though from version 2.8 conf.d will not be used anymore (buttom up)



    • [root@mon conf.d]# icinga2 api setup

    information/cli: Generating new CA.

    critical/cli: CA files '/var/lib/icinga2/ca//ca.crt' and '/var/lib/icinga2/ca//ca.key' already exist.

    warning/cli: Found CA, skipping and using the existing one.

    information/cli: Private key file '/var/lib/icinga2/certs//mon.key' already exists, not generating new certificate.

    information/cli: API user config file '/etc/icinga2/conf.d/api-users.conf' already exists, not creating config file.

    information/cli: Enabling the 'api' feature.

    warning/cli: Feature 'api' already enabled.

    Done.


    Now restart your Icinga 2 daemon to finish the installation!




    /**

    * The APIUser objects are used for authentication against the API.

    */

    object ApiUser "root" {

    password = "5bf35ec5ddae2ffc"

    // client_cn = ""


    permissions = [ "*" ]

    }



    [root@mon conf.d]# icinga2 --version

    icinga2 - The Icinga 2 network monitoring daemon (version: r2.8.0-1)


    Copyright (c) 2012-2017 Icinga Development Team (https://www.icinga.com/)

    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>

    This is free software: you are free to change and redistribute it.

    There is NO WARRANTY, to the extent permitted by law.


    Application information:

    Installation root: /usr

    Sysconf directory: /etc

    Run directory: /run

    Local state directory: /var

    Package data directory: /usr/share/icinga2

    State path: /var/lib/icinga2/icinga2.state

    Modified attributes path: /var/lib/icinga2/modified-attributes.conf

    Objects path: /var/cache/icinga2/icinga2.debug

    Vars path: /var/cache/icinga2/icinga2.vars

    PID path: /run/icinga2/icinga2.pid


    System information:

    Platform: CentOS Linux

    Platform version: 7 (Core)

    Kernel: Linux

    Kernel version: 3.10.0-514.el7.x86_64

    Architecture: x86_64


    Build information:

    Compiler: GNU 4.8.5

    Build host: unknown

  • Quote

    What is the diffenrent between /etc/icinga2/conf.d/api-users.conf and /etc/icinga2/features-available/api.conf ?

    api.conf is for configuring your api. conf.d/api-users.conf is the default/example place to configure your api-users.


    Where do you have this, and is this the user you have configured for your director ?:



    Quote

    I though from version 2.8 conf.d will not be used anymore (buttom up)


    conf.d has nothing to do with buttom-up. Its the default/example path for local configuration files, like the api-users.

  • hi

    the ApiUser "root" is located under /etc/icinga2/conf.d after icinga2 api setup


    ist it possible to test with curl command directly to the api on endpoints ?


    i saw some of the other posted used "director" instead of root ,did i missed any thing in config

  • comment out /* Include conf.d in icinga2.conf */

    the ApiUser "root" is located under /etc/icinga2/conf.d

    I just want to be sure: If you say "comment out" you mean you removed the "/*" and the "*/" or you inserted it ?

    Code
    1. icinga2 object list --type=ApiUser #gives you all configured api users
  • You can configure the ApiUser anywhere you want, just ensure it is a local secure location which is included by icinga2.conf


    If you want to test the REST API, start reading the corresponding chapter inside the Icinga 2 docs. Everything you need is explained with examples there. Hint aside: The Director uses config packages for deployment, but also other things.

  • hi,


    i removed the comment on icinga2.conf



    include_recursive "conf.d"


    used the root / pass in /etc/icinga2/conf.d/api-users.conf


    then

    icinga2 daemon -C

    systemctl restart icinga2


    still Error 182


    Reboot Icinga2 Master


    worked great no more API 182 error and Director can import database .


    many thanks !

  • A shorter way to only include a specific file is


    Code
    1. include "conf.d/api-users.conf"


    This works with relative and absolute paths.