Question

SSH check command did I missed something ?

  • 23 May 2023
  • 7 replies
  • 199 views

Badge +6

I assumed that I followed this tutorial : Linux SSH | Centreon Documentation

  • created a ro_ssh_centreon on the hosts that I whant to monitor
  • used the centreon-engine user on centreon server
  • created the ssh key and then copy the key to the host that I whant to monitor and then get a ssh connexion to , but needed the ro_ssh_centreon user password 

So , now I’m not sure if it’s working or not when I try using os-linux-ssh-connection-custom .

From centreon with the perl script:

[centreon-engine@XXXXXXXX ~]$ /usr/lib/centreon/plugins//centreon_linux_ssh.pl --plugin=os::linux::local::plugin --mode=connections --hostname='XX.XXX.X.X' --ssh-backend='libssh' --ssh-username='ro_ssh_centreon' --ssh-port='22' --ssh-priv-key=/var/lib/centreon-engine/.ssh/id_ed25519 --warning='' --critical=''

OK: Total connections: 4 | 'total'=4;;;0; 'con_established'=4;;;0; 'con_synSent'=0;;;0; 'con_synReceived'=0;;;0; 'con_closed'=0;;;0; 'con_timeWait'=0;;;0; 'con_listen'=12;;;0; 'con_finWait2'=0;;;0; 'con_finWait1'=0;;;0; 'con_closing'=0;;;0; 'con_closeWait'=0;;;0; 'con_lastAck'=0;;;0;

 

From the Host (ssh service):

 root@XXXXXXXXX  ~  systemctl status sshd

● ssh.service - OpenBSD Secure Shell server

     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)

     Active: active (running) since Tue 2023-05-09 17:00:47 CEST; 1 weeks 6 days ago

       Docs: man:sshd(8)

             man:sshd_config(5)

    Process: 489 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)

    Process: 457672 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)

    Process: 457673 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)

   Main PID: 521 (sshd)

      Tasks: 1 (limit: 28817)

     Memory: 8.1M

        CPU: 2min 30.825s

     CGroup: /system.slice/ssh.service

             └─521 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

mai 23 08:26:27 XXXXXXXXXX sshd[476839]: Connection closed by invalid user centreon-engine XX.XXX.X.X port 55246 [preauth]

mai 23 08:31:27 XXXXXXXXXX sshd[476935]: Invalid user centreon-engine from 10.250.1.7 port 48320

mai 23 08:31:27 XXXXXXXXXX sshd[476935]: Connection closed by invalid user centreon-engine XX.XXX.X.X port 48320 [preauth]

mai 23 08:35:29 XXXXXXXXXX sshd[476978]: Accepted password for root from XX.XXX.X.X port 59103 ssh2

mai 23 08:35:29 XXXXXXXXXX sshd[476978]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0)

mai 23 08:35:30 XXXXXXXXXX sshd[476981]: Accepted password for root from XX.XXX.X.X port 59104 ssh2

mai 23 08:35:30 XXXXXXXXXX sshd[476981]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0)

mai 23 08:35:52 XXXXXXXXXX sshd[477069]: Accepted publickey for ro_ssh_centreon from XX.XXX.X.X port 59394 ssh2: ED25519 SHA256:RqDrE6hrJ51saGe3yCjf+TJuwXSXlrRCLYTzT/jXKIg

mai 23 08:35:52 XXXXXXXXXX sshd[477069]: pam_unix(sshd:session): session opened for user ro_ssh_centreon(uid=1001) by (uid=0)

mai 23 08:35:52 XXXXXXXXXX sshd[477069]: pam_unix(sshd:session): session closed for user ro_ssh_centreon

 

From centreon WebUI

 

But I have this in the script perl :

 

Thx


7 replies

Userlevel 6
Badge +18

Hi @Marchal-l try to put the value of SSHEXTRAOPTIONS between quote

Badge +6

Hi @Laurent 

I showed 2 pics where I tried to set up le os-linux-connections-SSH-custom .

I don’t understand why the script doen’t change when I change options and arguments.

If I run the command from centreon server , I can see the SSH connexion in the ssh service status on the host.

1st I’m sure it’s from the WebUI the 2nd is from CLI 

mai 23 12:16:32 lrfdocker03sv sshd[482124]: Connection closed by invalid user centreon-engine 10.250.1.7 port 51912 [preauth]

 


mai 23 12:20:52 lrfdocker03sv sshd[482196]: Accepted publickey for ro_ssh_centreon from 10.250.1.7 port 60246 ssh2: ED25519 SHA256:RqDrE6hrJ51saGe3yCjf+TJuwXSXlrRCLYTzT/jXKIg
 

So I tried what you recommand , it doesn’t change anythig,.

Thx.

 

Userlevel 6
Badge +18

Did you generate and export new configuration?

Badge +6

Yep !

It’s a reflex for now.

 

Userlevel 4
Badge +13

Yep !

It’s a reflex for now.

 

😂😎

Userlevel 4
Badge +13

The macro for the username comes from the host, make sure you are setting it there in your template/command “OS-Linux-Connections-SSH-custom” ( Configuration  >  Commands  >  Checks ) as it looks like custom custom one. 

 

 

--ssh-username='$_HOSTSSHUSERNAME$' 

 

Badge +6

Hi, 

 @ponchoh I just saw your answer ..

I gonna test that a bit later, as you see I continu to play with centreon.. 

Thx.

Reply