glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
212 stars 51 forks source link

Inventory not performed via ssh and snmp with Toolbox on Ubuntu #620

Closed BoggyLeVaillant closed 3 weeks ago

BoggyLeVaillant commented 3 months ago

Bug reporting acknowledgment

Yes, I read it

Professional support

Still not applicable

Describe the bug

I have the Nightly build of GLPI-Agent: GLPI-Agent-1.8-git59e6e18c for linux installed on my ubuntu server.

For SSH :

When I am trying to run the inventory via ssh protocol on a port 22, I get the error :

[error] #1, Can't trust <<MY_IP>> for ssh remoteinventory: -46 LIBSSH2_ERROR_KNOWN_HOSTS Host key verification failed: unable to perform the check. 

I tried, with the same configuration on a windows computer and it worked.

For SNMP v2c :

Also when I am trying to send SNMP data to my GLPI server, I get the error :

[error] #0273, [http client] communication error: 400 Bad Request, JSON does not validate. Violations:, Required property missing: type, data: {"ips":["127.0.0.1","192.168.1.16"],"mac":"00:10:40:dc:4e:34","manufacturer":"Honeywell","memory":0,"name":"PC43d-054C2220132","ram":121,"serial":"054C2220132","uptime":"27 da (...)

The data is saved if the target is local, but if I try to send it to the server it I get this message, for some IPs and for others, I get no message, and the GLPI server is not updated.

Also, I tried winrm and it worked well, to send data to the server. So I think that my configuration is right and maybe the problem comes from the Linux version.

To reproduce

Have GLPI-Agent-1.8-git59e6e18c for linux with Toolbox Enabled

For SSH :

Create ssh credential Create the IP range only with the target IP, starting and ending IP

For SNMP :

Create snmp v2c credential Create the IP range to scan a full network

Expected behavior

Remote inventory via ssh protocol and snmp protocol to GLPI server

Operating system

Linux

GLPI Agent version

Nightly build (git version in additional context below)

GLPI version

10.0.12

GLPIInventory plugin or other plugin version

Not applicable

Additional context

No response

g-bougard commented 3 months ago

Hi @BoggyLeVaillant

first of all, for the SNMP case, it seems you want to inventory a computer: as this is explained in documentation, SNMP inventory is only for network devices & printers, this simply doesn't work for computers. Anyway, even in that case, you should obtain a different error as type should be set to COMPUTER, that's weird. Can you enable debug2 level, retry and share the failing submitted json you'll find in the log ?

For the ssh case, the error LIBSSH2_ERROR_KNOWN_HOSTS Host key verification failed: unable to perform the check. is a security check and can be specific you your computer context. Are you at least able to connect via ssh on the commandline from that computer ? What's the operating system linux flavour and version ? Can you check the libssh2 package installed version ?

BoggyLeVaillant commented 3 months ago

Hello,

Thank you for your reply. The thing is that I tried on different OS (Linux and Windows) and I got the same error for both. But you are right. The printers I get are sent to the GLPI server.

Regarding libssh2 error, I am able to connect to that computer using ssh, from my Ubuntu 22.04 computer. I have also checked and libssh2 is installed. I tried to execute this on Windows and it worked well. I also checked the credentials many times but still get the same error.

g-bougard commented 3 months ago

Do you mean you have the libssh2 error on your Ubuntu 22.04 where you manage to connect to the remote computer ?

You should also consider the agent is probably running as root so you have to test you can access the remote computer as root. Maybe libssh2 fails because the root ~/.ssh folder is not existing and it may starting to work after you commandline test as root.

g-bougard commented 1 month ago

Hi @BoggyLeVaillant

back to your issue, did you figure out your problem ?

On windows, do you have a C:\Program Files\GLPI-Agent\var\.ssh\known_hosts file created by the agent ? And at least the parent folder ?

BoggyLeVaillant commented 1 month ago

Hello,

Sorry for this late response, I am currently working on another subject. I completly forgot about GLPI-Agent. Sorry about that. I might contact you again when I'll be working on this project.

g-bougard commented 3 weeks ago

Hi @BoggyLeVaillant

I'm closing this issue. New release has been published since then. So feel free to reopen or open a new issue after testing with the latest version if you're back on this project.