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

Error after enabling TFA in Proxmox host #36

Closed
oezh opened this issue Jul 17, 2020 · 16 comments
Closed

Error after enabling TFA in Proxmox host #36

oezh opened this issue Jul 17, 2020 · 16 comments

Comments

@oezh
Copy link

oezh commented Jul 17, 2020

cv4pve-autosnap was working flawlessly until 2FA was enabled. It's running from a local machine inside the same network.

Here is the command and the result:

cv4pve-autosnap --host=10.0.1.1 --username=root@pam --password=PASSWORD --vmid="100" snap --label='mediodía' --keep=1 --debug

Method: POST, Url: https://10.0.1.1:8006/api2/json/access/ticket
Parameters:
password : PASSWORD
username : root
realm : pam
StatusCode: OK
ReasonPhrase: OK
IsSuccessStatusCode: True
{
"data": {
"clustername": "Cluster",
"NeedTFA": 1,
"username": "root@pam",
"CSRFPreventionToken": "5F11EA78:aSSo+iNEUzoVR4xrBagTdHqdBdRAKXiXSxjUqmD5u80",
"ticket": "PVE:tfa!root@pam:5F11EA78::iOsiFA3xER3OncdByrFziOwnefCm92JDWKoQU4/vbDO0Fu0S1s+tbBRud/k8wXd7DesBjoyL7z5jUKHizPMtEjUIS0b06sgeXtbbK/V7tN/FdGEPeQ357tI8wymLeoTAfwCL1UruSyl6jczDE1x3kTAwDOdRsa/jXZc7clLT1+rgIL32EsTob8swtgo883QgSglfhaXFspfvDRjvVF9L8XsCa3ofPPJlnL8kvw5EadebUnzFCRFamALczAHsBAmKrAqt/eoWW+v0VKb3BDb1h8L6rA2zhz/Ic3r+O/iYKj2cy0opNZQUN0mWIPOqwUCmhAK1rSY/C9MyUXtZupZaew=="
}
}

ACTION Snap
VMs: 100
Label: mediodia
Keep: 1
State: False
Phase: snap-job-start
Method: GET, Url: https://10.0.1.1:8006/api2/json/cluster/resources?type=vm
StatusCode: Unauthorized
ReasonPhrase: No ticket
IsSuccessStatusCode: False
null

================ EXCEPTION ================
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
'System.Dynamic.ExpandoObject' does not contain a definition for 'data'
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at Corsinvest.ProxmoxVE.Api.Extension.VM.ClientExtension.GetVMs(PveClient client)
at Corsinvest.ProxmoxVE.Api.Extension.VM.ClientExtension.GetVMs(PveClient client, String jolly)
at Corsinvest.ProxmoxVE.AutoSnap.Commands.Snap(String vmIdsOrNames, String label, Int32 keep, Boolean state)
at Corsinvest.ProxmoxVE.AutoSnap.ShellCommands.<>c__DisplayClass6_1.b__1()
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass144_0.b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Corsinvest.ProxmoxVE.Api.Extension.Helpers.Shell.ShellHelper.ExecuteConsoleApp(CommandLineApplication app, TextWriter stdOut, String[] args)

@franklupo
Copy link
Member

Hi,
2FA is not supported

@franklupo
Copy link
Member

Hi,
which version use of Proxmox VE?

@oezh
Copy link
Author

oezh commented Jul 22, 2020

6.2-10

@franklupo
Copy link
Member

My idea is add new parameter --api--token

@oezh
Copy link
Author

oezh commented Jul 22, 2020

Excellent. I'm no developer, but if you need some testing, let me know.

franklupo added a commit that referenced this issue Jul 23, 2020
@franklupo
Copy link
Member

Excellent. I'm no developer, but if you need some testing, let me know.

Test the last release https://github.com/Corsinvest/cv4pve-autosnap/releases/tag/v1.9.2
new parameter --api-token

@oezh
Copy link
Author

oezh commented Jul 24, 2020

What format should I use --Api-token? The example format in README.md using my own Api Token, gave me the error: "app=XXXXXXX: event not found"

@franklupo
Copy link
Member

franklupo commented Jul 24, 2020

Hi,
the format is USER@REALM!TOKENID=UUID
eg "root@pam!app=8a8c1cd4-d373-43f1-b366-05ce4cb8061f"

App is a TokenId example. You can create any name

@oezh
Copy link
Author

oezh commented Jul 24, 2020

I created Api Token via web interface for user root, with Token ID = "app" Privilege Separation = "unchecked" and expire = "never"
then I run this command:

cv4pve-autosnap --host=10.0.1.1 --api-token=root@pam!app=85725905-39f9-4510-920c-fff1435cea74 --vmid="100" snap --label='test' --keep=1 --verbose

And I get this error:
-bash: !app=85705905: event not found

is my command wrong?

@franklupo
Copy link
Member

Execute with --debug and attach output

Best regards

@franklupo
Copy link
Member

franklupo commented Jul 25, 2020

I created Api Token via web interface for user root, with Token ID = "app" Privilege Separation = "unchecked" and expire = "never"
then I run this command:

cv4pve-autosnap --host=10.0.1.1 --api-token=root@pam!app=85725905-39f9-4510-920c-fff1435cea74 --vmid="100" snap --label='test' --keep=1 --verbose

And I get this error:
-bash: !app=85705905: event not found

is my command wrong?

Quote --api-token value

@oezh
Copy link
Author

oezh commented Jul 26, 2020

Here are 3: no quotes, double quotes and single quotes. --debug activated:

`# cv4pve-autosnap --host=10.0.1.1 --api-token=root@pam!app=85705905-39f9-4110-970c-fff0435cea74 --vmid="100" snap --label='test' --keep=1 --debug
-bash: !app=85705905: event not found

cv4pve-autosnap --host=10.0.1.1 --api-token="root@pam!app=85705905-39f9-4110-970c-fff0435cea74" --vmid="100" snap --label='test' --keep=1 --debug

-bash: !app=85705905: event not found

cv4pve-autosnap --host=10.0.1.1 --api-token='root@pam!app=85705905-39f9-4110-970c-fff0435cea74' --vmid="100" snap --label='test' --keep=1 --debug

Specify --help for a list of available options and commands.
Unrecognized option '--api-token=root@pam!app=85705905-39f9-4110-970c-fff0435cea74'`

@oezh
Copy link
Author

oezh commented Jul 26, 2020

Ok I got it to run. For some reason, cv4pve-autosnap was not being updated with the downloaded version. Had to replace manually in /usr/bin and /usr/local/bin and now it works. It works with single quotes in --api-token value. Now I'm going to enable back TFA and will let you know. Thanks!!

@oezh
Copy link
Author

oezh commented Jul 26, 2020

If using Privilege Separation, which permissions should I enable? I enabled VM.snapshot and path /vms but is not working

@franklupo
Copy link
Member

you have to try from web interface

@cheechmarino
Copy link

If using Privilege Separation, which permissions should I enable? I enabled VM.snapshot and path /vms but is not working

Try VM.Audit and VM.Snapshot

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

No branches or pull requests

3 participants