[GH-ISSUE #140] reset vm root password #71

Closed
opened 2026-02-27 15:46:17 +03:00 by kerem · 1 comment
Owner

Originally created by @nadermx on GitHub (Jun 2, 2023).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/140

Hi, I see that the API offers this https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/set-user-password

And I see the qm command offers it

qm guest passwd <vmid> <username> [OPTIONS]

Sets the password for the given user to the given password

<vmid>: <integer> (1 - N)

    The (unique) ID of the VM.
<username>: <string>

    The user to set the password for.
--crypted <boolean> (default = 0)

    set to 1 if the password has already been passed through crypt()

But honestly I can't seem to get any variation of the wrapper to execute it.

def reset_vps_root_pw(vmid, new_password):
    vm = proxmox.nodes(proxmox_node).qemu(vmid)
    data = {
        'userid': 'root',
        'password': new_password
    }
    vm.agent.post('set-user-password', data=data, expected_status_code=204)
    print("Root password reset successfully.")

Seems to be about the closest I got, any help would be appreciated

Edit:
Also tried this, which seems to run, but does not actually reset the password

def reset_vps_root_pw(vmid, new_password):
    vm = proxmox.nodes(proxmox_node).qemu(vmid).agent()
    vm.set_user_password(new_password)
    print("Root password reset successfully.")

Originally created by @nadermx on GitHub (Jun 2, 2023). Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/140 Hi, I see that the API offers this `https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/set-user-password` And I see the qm command offers it ``` qm guest passwd <vmid> <username> [OPTIONS] Sets the password for the given user to the given password <vmid>: <integer> (1 - N) The (unique) ID of the VM. <username>: <string> The user to set the password for. --crypted <boolean> (default = 0) set to 1 if the password has already been passed through crypt() ``` But honestly I can't seem to get any variation of the wrapper to execute it. ``` def reset_vps_root_pw(vmid, new_password): vm = proxmox.nodes(proxmox_node).qemu(vmid) data = { 'userid': 'root', 'password': new_password } vm.agent.post('set-user-password', data=data, expected_status_code=204) print("Root password reset successfully.") ``` Seems to be about the closest I got, any help would be appreciated Edit: Also tried this, which seems to run, but does not actually reset the password ``` def reset_vps_root_pw(vmid, new_password): vm = proxmox.nodes(proxmox_node).qemu(vmid).agent() vm.set_user_password(new_password) print("Root password reset successfully.") ```
kerem 2026-02-27 15:46:17 +03:00
Author
Owner

@jhollowe commented on GitHub (Jun 2, 2023):

you need to use the parameter names from the API docs you linked to directly instead of in data.

So the call would be vm.agent("set-user-password").post(username='root', password=new_password) (assuming you have not already encrypted the password)

I haven't tested this, but that should be what you need. Please reopen if that doesn't work for you!

<!-- gh-comment-id:1573739963 --> @jhollowe commented on GitHub (Jun 2, 2023): you need to use the parameter names from the API docs you linked to directly instead of in `data`. So the call would be `vm.agent("set-user-password").post(username='root', password=new_password)` (assuming you have not already encrypted the password) I haven't tested this, but that should be what you need. Please reopen if that doesn't work for you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmoxer#71
No description provided.