two factor otp auth for provider #1418
Replies: 6 comments 1 reply
-
Hi @vanillaSprinkles 👋🏼 I'm curious about your use case for OTP with the provider. Would a separate API Token used exclusively for the provider auth work for you instead? OTP is primarily designed for interactive logins, where the user must enter their password as the first factor, and an OTP as a second factor provided from an independent/external source. For system-to-system auth, like between the provider and PVE, the API Token is the preferred method, as it can be better protected than the user's password, have a shorter lifetime, be easily tailored to a subset of permissions, revoked, etc.
Not quite sure I've got this. PVE REST API auth and SSH auth are technically independent of each other. For any production systems, you should not use the root user account, which is configured by default and allows you to authenticate both with the PVE API and SSH. Instead, I highly recommend setting up a separate API Token for API access, and a non-privileged sudo user for SSH, and configuring public key auth via ssh-agent. I believe you can dynamically load ssh key(s) to the ssh-agent using direnv config, but I don't have much experience with it. |
Beta Was this translation helpful? Give feedback.
-
for use case with otp: Like for AWS auth'ing, the user can pass in user/pass + totp, which grants an hour (or custom) time limit for the session based auth (access-key, secret-access-key, session-token) - and I do think that would be a nice flow for proxmox (although proxmox's is simply access/ticket and passes the ticket (pveauthcookie) around - and from my few tests the csrf prevention token is not required). so the flow for aws is like user has their non-changing creds + totp and that yields a time-limited session-credential set; which due to totp makes it a bit more ideal than a long term non-rotating credential. for that last "and finally" that i wrote: im hoping to not use ssh to send commands to manage proxmox - i basically use direnv to manage my secrets as I can have it trigger things based on a folder I am working within. My goal is to have root only used for bootstrapping the system, create a pve-realm'd user with more "full" access, with totp, and eventually have scoped privs for lower ranking users (and then locking down root to 127.0.0.1 access with totp only; and ssh to the system would also never be root; a different stage of 'bootstrapping' for the OS) - but certainly im not trying to have a workflow where a user logs into webui, creates a short-lived (several hours) api-token then add that to secrets for TF to use - thats what I believe totp handles (the random auth component) more edits: |
Beta Was this translation helpful? Give feedback.
-
i actually got to play around in the provider go files a little bit today.. (found it more of a pain to test the local build with tofu than anything else - but that is another problem for another day) managed to make the provider accept the still need to run through a bit of cleanup before i send a PR for review and critiquing - be another day or so ish |
Beta Was this translation helpful? Give feedback.
-
@bpg i finally made a fork and PR of my stuff (to my fork) before i finish a few things (namly only an edge-case stack-trace i found with invalid inputs - and some more docs like using curl to auth with TOTP): https://github.com/vanillaSprinkles/fork__bpg__terraform-provider-proxmox/pull/1/files curious on a few things:
|
Beta Was this translation helpful? Give feedback.
-
sounds good, i'll try to fixup that stack trace then PR into upstream soon edit: woo here we go: #1441 i have not done much golang so critique away (and add all the reasons) - i added a few cheers! |
Beta Was this translation helpful? Give feedback.
-
been fun so far; ended up going with
|
Beta Was this translation helpful? Give feedback.
-
i've gone over some of the PRs re auth and documentation stuff, but I could not quite find out exactly why the
otp
option (orPROXMOX_VE_OTP
env-var) is marked for deprecation ( at https://registry.terraform.io/providers/bpg/proxmox/latest/docs#otp )I was trying to get it working in proxmox 8.2.2 with provider 0.60.1 but getting a bit of auth-errors (when disabling the users totp then auth works with user/pass - so guessing the ticket'ing bit changed with proxmox 8).
Curious if the (when it worked)
otp
mode in the provider created its own new session ticket every time running a plan/apply, or if it reused one...And finally hoping to see some level of support for it (though since im using direnv i may just stick to user/pass over ssh-agent), even if its a helper-agent that passes along the
ticket
and theCSRFPreventionToken
stringsEDIT: resolved with merge of #1441
Beta Was this translation helpful? Give feedback.
All reactions