Ad Widget

Collapse

TRY TO RESOLVE - (Monitoring mikrotik via SSH) / ( Failed to verify the host key)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lfsousa17
    Junior Member
    • Nov 2017
    • 8

    #1

    TRY TO RESOLVE - (Monitoring mikrotik via SSH) / ( Failed to verify the host key)

    Forgive my English, I'm Brazilian.
    After several attempts to get this monitoring by snmp and not working (I did not find the OID or there are no rsrsrs)
    I'm trying to get zabbix to connect via ssh on my mikrotik router, so I can send a ping command to an ip from the internet.
    The purpose of this is to monitor my load balancing link.

    I'm using Debian GNU / Linux 9 (stretch) and zabbix 3.4.4.

    I'll explain exactly how I'm going to do this.

    First I created a user named zabbix on my router with read permission, I installed sshpass (apt get install sshpass) to be able to send the password along with the command to my router, after that I tested the connection
    sshpass -p routerpassword ssh userrouter@iprouter ping 8.8.8.8 and everything works perfectly.

    I configured the zabbix agent to use the user parameter and executed the command, edited the agent configuration file and added the command

    UserParameter = item, sshpass -p routerpassword ssh userrouter@iprouter ping router 8.8.8.8, I saved the file and restarted the zabbix agent.

    I ran into the following error
    Could not create directory '/var/lib/zabbix//.ssh'
    Failed to verify host key.

    And that does not return the expected value, I created the .ssh file inside the / var / lib / zabbix directory and left it empty, so I edited the / etc / ssh / sshd_config file and added the lines

    Root of AllowUsers
    AllowUsers zabbix

    I saved the file and restarted the ssh service,

    now I come across the following error
    Failed to verify host key.

    And I do not know what else to do.
    Last edited by lfsousa17; 03-04-2018, 15:42.
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Hello, lfsousa17!

    I would suggest to generate SSH keys and establish passwordless authorization between zabbix server and mikrotik router.
    Take a look at https://catonrug.blogspot.com/2018/0...ik-zabbix.html

    Let me know how it goes

    Regards,
    Aigars

    Comment


    • lfsousa17
      lfsousa17 commented
      Editing a comment
      Hello aigars.kadikis thanks for replying, I was able to generate the SSH keys and establish the connection via SSH without password through the zabbix server.
      However, I'm going to execute a direct command on the mikrotick terminal, and zabbix will return the output of the command and this information is too big, I would like to do something like ping | grep received | awk '{print $ 1}', but that does not seem possible to me.
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #3
    Hi, fsousa17!

    Since grep and awk is not build in in mikrotik terminal then we need different solution. Sounds like we can execute external script which contains something like:
    Code:
    #!/bin/bash
    ssh [email protected] "ping 8.8.8.8 count 4" | egrep -o "packet-loss=([0-9]+)"
    just tested it and it does the job.

    What do you mean by "information is too big"? I mean the the only thing we are limited is "Timeout="
    You probably need to set it to maximum in zabbix_server.conf
    HTML Code:
    Timeout=30
    and
    Code:
    systemctl restart zabbix-server
    Regards,
    Aigars

    Comment

    Working...