# "by\_ssh" plugin and ssh private key on satellite

**URL:** <https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603>\
**Category:** Icinga 2\
**Created:** [October 2, 2026, 5:22pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603 "2026-10-02T17:22:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![monigacom](https://community.icinga.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@monigacom](https://community.icinga.com/u/monigacom)\
**Post date:** [October 2, 2026, 5:22pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/1 "2026-10-02T17:22:19Z")

</div>

Hi,

I want to setup a service apply rule n global templates to run it across various zones. I’m not using icinga2 agent or Director. I’ve the ssh private key available on all satellites which I want to use for ssh connection in this rule. Is there a way to use the key on the satellite and have it run a ssh command on the remote host?

Thanks

---

<div class="post-metadata">

**Author:** ![cbreit](https://community.icinga.com/letter_avatar_proxy/v4/letter/c/5e9695/32.png) [@cbreit](https://community.icinga.com/u/cbreit)\
**Post date:** [October 5, 2026, 7:42am UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/2 "2026-10-05T07:42:11Z")

</div>

Hi @monigacom,

did you try to set the command\_endpoint attribute in your service definition? This should be exactly what you were looking for.

> **[Service - Object Types - Icinga 2](https://icinga.com/docs/icinga-2/latest/doc/09-object-types/#service)**
>
> This chapter provides an overview of all available config object types which can be instantiated using the object keyword.

Best Regards  
Christoph

---

<div class="post-metadata">

**Author:** ![log1c](https://community.icinga.com/user_avatar/community.icinga.com/log1c/32/2071_2.png) [@log1c](https://community.icinga.com/u/log1c)\
**Post date:** [October 6, 2026, 7:31am UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/3 "2026-10-06T07:31:04Z")

</div>

The Icinga team published a guide on how to setup the checks via SSH:

> **[How to do Agentless Monitoring with check\_by\_ssh](https://icinga.com/blog/how-to-do-agentless-monitoring-with-check_by_ssh/)**
>
> Icinga 2 can use SSH connections to execute remote check plugins instead of using the agent. Doing so comes with challenges, addressed here.

The `command_endpoint` attribute is not necessary for this. You just need to put the host config in the correct `zone` folder on your master, so that they are monitored be the correct satellite.

---

<div class="post-metadata">

**Author:** ![monigacom](https://community.icinga.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@monigacom](https://community.icinga.com/u/monigacom)\
**Post date:** [October 6, 2026, 10:25pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/4 "2026-10-06T22:25:54Z")

</div>

I agree. I’ve this service rule setup but having trouble getting it work either because of the quotes and/or remote command shell executon of the command.

```auto
apply Service for (service_display_name => proc_details in 
{"Registry_Process" = { command = "registry", crit = "1:1" },"Docker_Daemon" = { command = "dockerd", crit = "1:1" },"Container_Daemon" = { command = "containerd", crit = "1:1" } }) {

import "generic-service"check_command = "by_ssh"

display_name = "check_" + service_display_name

//vars.by_ssh_command = "/usr/local/nagios/libexec/check_procs -C " + proc_details.command + " -c " + proc_details.crit

vars.by_ssh_command = [
"/usr/local/nagios/libexec/check_procs",
"-C", proc_details.command,
"-c", proc_details.crit
]

vars.by_ssh_options = ["StrictHostKeyChecking=no"]
vars.by_ssh_quiet = true
vars.by_ssh_arguments = {
   "-E" = {
       set_if = true
       description = "Skip STDERR output lines"
   }
}

vars.by_ssh_logname = "user"

vars.by_ssh_identity = "/usr/local/icinga/libexec/user_id_rsa"

assign where host.name == "test-host1"

}

```

I get error - Remote command execution failed: /usr/local/nagios/libexec/check\_procs: invalid option – ‘E’

---

<div class="post-metadata">

**Author:** ![monigacom](https://community.icinga.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@monigacom](https://community.icinga.com/u/monigacom)\
**Post date:** [October 6, 2026, 11:26pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/5 "2026-10-06T23:26:41Z")

</div>

Removed ssh argment -E and it fixed the problem.

---

<div class="post-metadata">

**Author:** ![apenning](https://community.icinga.com/user_avatar/community.icinga.com/apenning/32/7669_2.png) [@apenning](https://community.icinga.com/u/apenning)\
**Post date:** [October 13, 2026, 12:29pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/6 "2026-10-13T12:29:04Z")

</div>

I am glad you found a solution!

> [@monigacom](#):
>
> ```auto
> vars.by_ssh_options = ["StrictHostKeyChecking=no"]
> 
> ```

Please don’t do this. This does not only weakens the transport, but disables all integrity and security constraints of SSH. Now, your monitoring can be MITMed.

In case of having a `~/.ssh/known_hosts` file is not feasible, consider adding the public keys to the Icinga 2 configuration.

1. Add a `ssh_pubkey` custom variable to your host.

```auto
object Host "test-host1" {
  // ...
  vars.ssh_pubkey = "ssh-ed25519 AAAAA[...]"
}

```

2. Pass the `ssh_pubkey` custom var via a `KnownHostsCommand` hack to `vars.by_ssh_options` in your Service object.

```auto
vars.by_ssh_options = [
  "StrictHostKeyChecking=yes",
  "KnownHostsCommand=/usr/bin/echo '%H $ssh_pubkey$'"
]

```

---

<div class="post-metadata">

**Author:** ![rivad](https://community.icinga.com/user_avatar/community.icinga.com/rivad/32/5852_2.png) [@rivad](https://community.icinga.com/u/rivad)\
**Post date:** [October 13, 2026, 1:46pm UTC](https://community.icinga.com/t/by-ssh-plugin-and-ssh-private-key-on-satellite/15603/7 "2026-10-13T13:46:18Z")

</div>

You could also start signing you public keys.

> **[If you’re not using SSH certificates you’re doing SSH wrong](https://smallstep.com/blog/use-ssh-certificates/)**
>
> SSH has some pretty gnarly issues when it comes to usability, operability, and security. The good news is this is all easy to fix. SSH is ubiquitous. It’s the de-facto solution for remote administration of \*nix systems. SSH certificate authentication...
