Ad Widget

Collapse

Remote script execution. AllowKey problem

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • core749
    Junior Member
    • Aug 2022
    • 2

    #1

    Remote script execution. AllowKey problem

    Hello guys!

    I have:
    Zabbix 6.2.1
    Windows Zabbix agent v6.2.1 (passive)
    Windows Server 2019

    I'm completely stumped. I need to start remote script execution with zabbix agent after trigger.

    The remote script looks like this:
    pwsh C:\Scripts\host_list\get_list.ps1 -ip {HOST.IP1}

    I want to protect myself from uncontrolled execution of the script on the host and write the following in the configuration:
    ̶A̶l̶l̶o̶w̶K̶e̶y̶=̶s̶y̶s̶t̶e̶m̶.̶r̶u̶n̶[̶"̶p̶w̶s̶h̶ ̶C̶:̶\̶S̶c̶r̶i̶p̶t̶s̶\̶V̶M̶s̶_̶l̶i̶s̶t̶\̶g̶e̶t̶_̶v ̶m̶.̶p̶s̶1̶ ̶*̶"̶]̶
    AllowKey=system.run["pwsh C:\Scripts\host_list\get_list.ps1 *"]
    But it doesn't work! At the same time, AllowKey=system.run[*] works perfectly.

    What is my problem?

    I have tried different variations like:
    AllowKey=system.run[pwsh C:\Scripts\host_list\get_list.ps1 *]
    AllowKey=system.run[pwsh C:\Scripts\host_list\get_list.ps1, *]
    AllowKey=system.run[pwsh.exe C:\Scripts\host_list\get_list.ps1 *]

    But unsuccessfully.
    From Zabbix Server I get this:
    Requested [system.run[pwsh C:\Scripts\host_list\get_list.ps1 -ip 172.10.11.45,nowait]]
    Key access denied: "system.run[pwsh C:\Scripts\host_list\get_list.ps1 -ip 172.10.11.45,nowait]"
    Sending back [ZBX_NOTSUPPORTED: Unsupported item key.]

    I will be glad to any advice!
    Last edited by core749; 04-08-2022, 14:22.
  • Answer selected by core749 at 05-08-2022, 11:23.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    Have you read carefully this page https://www.zabbix.com/documentation...n-and-allowkey ?
    I think it nicely shows what's up here..
    You probably should define your AllowKey as
    AllowKey=system.run["pwsh C:\Scripts\VMs_list\get_vm.ps1 *",*]
    notice the 2 *-s.... one for allowing script with parameter and other for wait/nowait for system.run

    Have to say here, I never done it myself.. Just pointing to docs...

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #2
      Have you read carefully this page https://www.zabbix.com/documentation...n-and-allowkey ?
      I think it nicely shows what's up here..
      You probably should define your AllowKey as
      AllowKey=system.run["pwsh C:\Scripts\VMs_list\get_vm.ps1 *",*]
      notice the 2 *-s.... one for allowing script with parameter and other for wait/nowait for system.run

      Have to say here, I never done it myself.. Just pointing to docs...

      Comment

      • core749
        Junior Member
        • Aug 2022
        • 2

        #3
        Originally posted by cyber
        Have you read carefully this page https://www.zabbix.com/documentation...n-and-allowkey ?
        I think it nicely shows what's up here..
        You probably should define your AllowKey as
        AllowKey=system.run["pwsh C:\Scripts\VMs_list\get_vm.ps1 *",*]
        notice the 2 *-s.... one for allowing script with parameter and other for wait/nowait for system.run

        Have to say here, I never done it myself.. Just pointing to docs...
        Damn it worked!
        Code:
        AllowKey=system.run[pwsh "C:\Scripts\host_list\get_list.ps1 *",*]
        I read the documentation, but it was very non-obvious to me.
        Thanks a lot. I wouldn't have figured it out myself. Quotes are very important.
        Last edited by core749; 04-08-2022, 19:52.

        Comment

        Working...