API auth failing

DLZ-TVotR

Member
Sep 2, 2020
10
1
8
33
I am new to restAPI/apis in general completely really so I am sure I am being stupid but wanted to ask.

looking at: https://pve.proxmox.com/wiki/Proxmox_VE_API


PVE uses a Token Based Authentication. All request to the API need to include that token inside a Cookie. We usually call that token a 'ticket'. Additionally, any write request must include a CSRF prevention token inside the HTTP header. The following examples use the 'curl' command line tool.

Example: get a new ticket and the CSRF prevention token

Code:
# curl -k -d "username=root@pam&password=yourpassword"  https://10.0.0.1:8006/api2/json/access/ticket
{ "data": {
  "CSRFPreventionToken":"4EEC61E2:lwk7od06fa1+DcPUwBTXCcndyAY",
  "ticket":"PVE:root@pam:4EEC61E2::rsKoApxDTLYPn6H3NNT6iP2mv...",
  "username":"root@pam"}
}

I am attempting to do so, but all I get in return is data:null

Code:
curl -k -d "username=root@pam&password=<redacted>" https://localhost:8006/api2/json/access/ticket
{"data":null}

I noticed the auth failure occurring in /var/log/auth.log on each attempt:

Code:
Sep 10 01:42:24 pve IPCC.xs[21478]: pam_unix(common-auth:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root

the password is definitely correct and is what I use to login to the UI, also at port 8006

I do have password auth turned off in /etc/ssh/sshd_config but I don't think this has anything to do at all with ssh?
 
hello,

maybe your password has special characters like !$ - if so you could try to put your password between 'single quotes' like the following example

Bash:
curl -k -d 'username=root@pam&password=yourpassword'  https://10.0.0.1:8006/api2/json/access/ticket
 
  • Like
Reactions: r.jochum

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!