Last active
July 12, 2024 00:38
-
-
Save digitalformula/f6fd7db90c64f4d1cd2acc678f0de715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to setup Proxmox API tokens | |
# Specifically for use with Home Assistant | |
# add user | |
pveum user add hass@pve -comment "Home Assistant" | |
# set user password | |
# you will be prompted for the new user's password here | |
pveum passwd hass@pve | |
# add group | |
pveum group add PowerMgmtUsers | |
# optional | |
pveum group add Auditors | |
# add user to group | |
# remove Auditors group if you're not using it | |
pveum user modify hass@pve --groups PowerMgmtUsers,Auditors | |
# add role | |
pveum role add PowerMgmt -privs "Sys.PowerMgmt" | |
# assign role to group | |
pveum acl modify / -group PowerMgmtUsers -role PowerMgmt | |
# optional | |
pveum acl modify / -group Auditors -role PVEAuditor | |
# add user api token | |
pveum user token add hass@pve shutdown -privsep 1 | |
# optional | |
pveum user token add hass@pve audit -privsep 1 | |
# assign role to token | |
pveum acl modify / -token 'hass@pve!shutdown' -role PowerMgmt | |
# optional | |
pveum acl modify / -token 'hass@pve!audit' -role PVEAuditor | |
# verify user permissions | |
# uncomment to show user permissions | |
# pveum user permissions hass@pve | |
# verify token permissions | |
# uncomment to show token permissions | |
# pveum user token permissions hass@pve shutdown | |
# pveum user token permissions hass@pve audit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment