proxmox access with curl and TFA

Hey,
instead of going the multiple trip route of obtaining a valid ticket, you could switch to using API keys and limit their capabilities to exactly what your script needs [0].
If you have to stick with obtaining a valid ticket, you have to take the ticket field from the response your initial request and send another request to the ticket endpoint with the previously obtained ticket as tfa-challenge, the username as username and the totp token as password formated as totp:123456

[0] https://pve.proxmox.com/wiki/Proxmox_VE_API#API_Tokens
 
anyone can help here?

my goal is to adapt the script /usr/share/doc/pve-manager/examples/spice-example-sh in order to use oauth token......
 
Hi Folke,
I can't get it working, can you post an example of the "curl" command I should write?
 
Bash:
# notice the -r in the jq command to prevent the result from being enclosed in quotation marks and escaped
curl -f -s -S -k --data-urlencode "username=root@pam" --data-urlencode "password=$PASSWORD" "https://cl1:8006/api2/json/access/ticket"|jq -r '.data.ticket' > cookie
# Don't know where you got that tfa-challenge should be a cookie, but it definitely shouldn't
curl --silent --insecure --data-urlencode "username=root@pam" --data-urlencode "password=totp:$(oathtool -b --totp "$TOTP_SECRET")" --data-urlencode "tfa-challenge=$(<cookie)" https://cl1:8006/api2/json/access/ticket

Generally, you can look at what your browser does to log you in by pressing F12 and look at the requests to the ticket endpoint in the networking tab (on Firefox).
 

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!