Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invalid usernameor password upon connection #44

Closed
MrSingingClub opened this issue Dec 15, 2023 · 5 comments
Closed

[BUG] Invalid usernameor password upon connection #44

MrSingingClub opened this issue Dec 15, 2023 · 5 comments
Labels
question Further information is requested

Comments

@MrSingingClub
Copy link

I followed the documentation to create a role, a user nagios@pam, a password and a an API token.
When I try the following or similar:
./check_pve.py -u 'nagios@pam' -p "<pass>" -k -e 10.10.7.9:8006/api2/json/ -m version -V 8.0.0
Then I get the error:
UNKNOWN - Could not fetch data from API: Could not connection to PVE API: invalid username or password
The same when using the token.

The user nagios exists in the OS. I can ssh using nagios.
The user exists in the Proxmox GUI. Password was set per command line as described in the guide here as well as using the GUI. Same for the token. The role and privileges are visible in the GUI.
When I follow the PVE documentation by doing:

curl --silent --insecure --data "username=nagios@pam&password=<pass>"  https://10.10.7.9:8006/api2/json/access/ticket| jq --raw-output '.data.ticket' | sed 's/^/PVEAuthCookie=/' > cookie 
curl  --insecure --cookie "$(<cookie)" https://10.10.7.9:8006/api2/json/nodes/$TARGETNODE/status | jq '.'

I get the data and no error.
I suspect the error message of the script is misleading and there is another error underlying.

Steps to reproduce the behavior:

  1. Follow the documentation here.
  2. Try the example.

Expected behavior
Get an icinga compatible result.

Environment (please complete the following information):
Linux 6.2.16-14-pve
PVE 8.0.4
Python 3.11.2

@MrSingingClub MrSingingClub added the bug Something isn't working label Dec 15, 2023
@nbuchwitz
Copy link
Owner

Does this also happen, if you're using the token based Auth method? See Readme for an example. Token based Auth is recommended with never proxmox versions

@MrSingingClub
Copy link
Author

Yes, by two ways: I created an api token at the command line as given in your guide and in a second try from scratch where I tried by creating the api token in the gui. Result is the same.

@nbuchwitz
Copy link
Owner

nbuchwitz commented Dec 17, 2023

./check_pve.py -u 'nagios@pam' -p "" -k -e 10.10.7.9:8006/api2/json/ -m version -V 8.0.0

API endpoint must not contain any paths. Endpoint and port can be specified via cli args and from that the check script composes the complete url. E.g. ./check_pve.py -u 'nagios@pam' -p "<pass>" -k -e 10.10.7.9 -m version -V 8.0.0

@nbuchwitz nbuchwitz added question Further information is requested and removed bug Something isn't working labels Dec 17, 2023
@MrSingingClub
Copy link
Author

That solved it. Thank you very much.
Maybe it would be worth to mention this in the documentation part. This site always refers to an API_ENDPOINT. The official Proxmox API doc (https://pve.proxmox.com/wiki/Proxmox_VE_API) states under API URL the full path.
Additionally, as it seems this script here always adds the port. Luckily I am using the default port. Would not know what to do if I would use any other port.

@nbuchwitz
Copy link
Owner

Fixed with #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants