Create admin user: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
== Install <code>sudo</code> on Proxmox == | |||
=== 1. Install <code>sudo</code> (if not present) === | |||
<syntaxhighlight lang="bash"> | |||
apt update && apt install sudo | |||
</syntaxhighlight> | |||
=== 2. Create an Administrative User === | |||
The script below will: | |||
* Create a new user (replace <code>asd</code> and password as needed). | |||
* Add the user to the <code>sudo</code> group. | |||
* Create an admin group in Proxmox's user management. | |||
* Assign the <code>Administrator</code> role. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
USER="asd" | USER="asd" | ||
PASS="asd" | PASS="asd" | ||
COMMENT="System Administrator" | COMMENT="System Administrator" | ||
if ! id "$USER" &>/dev/null; then | if ! id "$USER" &>/dev/null; then | ||
sudo useradd -m -s /bin/bash "$USER" && echo "$USER:$PASS" | sudo chpasswd | sudo useradd -m -s /bin/bash -G sudo "$USER" && echo "$USER:$PASS" | sudo chpasswd | ||
fi | fi | ||
pveum groupadd admin --comment "${COMMENT} group" 2>/dev/null | pveum groupadd admin --comment "${COMMENT} group" 2>/dev/null | ||
pveum aclmod / --group admin --role Administrator | pveum aclmod / --group admin --role Administrator | ||
pveum useradd "${USER}@pam" --comment "${COMMENT}" --groups admin 2>/dev/null | pveum useradd "${USER}@pam" --comment "${COMMENT}" --groups admin 2>/dev/null | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 3. Remove the Created User and Group === | |||
To delete the user and associated group: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
USER="asd" | USER="asd" | ||
sudo deluser --remove-home "$USER" | sudo deluser --remove-home "$USER" | ||
pveum user delete "${USER}@pam" 2>/dev/null | pveum user delete "${USER}@pam" 2>/dev/null | ||
pveum group remove admin 2>/dev/null | pveum group remove admin 2>/dev/null | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4. (Optional) Disable Root GUI Access === | |||
For enhanced security, disable root login for the Proxmox web GUI: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 30: | Line 42: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== To re-enable root access to GUI: ==== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
pveum user modify root@pam --enable 1 | pveum user modify root@pam --enable 1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Notes:''' | |||
* Change all hardcoded credentials before using in production! | |||
* Assigning <code>Administrator</code> to a non-root user allows you to safely disable root UI access. | |||
* All commands require root/sudo privileges on your Proxmox host. | |||
[[Category:Proxmox]] | |||
Revision as of 11:43, 15 July 2025
Install sudo on Proxmox
1. Install sudo (if not present)
apt update && apt install sudo
2. Create an Administrative User
The script below will:
- Create a new user (replace
asdand password as needed). - Add the user to the
sudogroup. - Create an admin group in Proxmox's user management.
- Assign the
Administratorrole.
USER="asd"
PASS="asd"
COMMENT="System Administrator"
if ! id "$USER" &>/dev/null; then
sudo useradd -m -s /bin/bash -G sudo "$USER" && echo "$USER:$PASS" | sudo chpasswd
fi
pveum groupadd admin --comment "${COMMENT} group" 2>/dev/null
pveum aclmod / --group admin --role Administrator
pveum useradd "${USER}@pam" --comment "${COMMENT}" --groups admin 2>/dev/null
3. Remove the Created User and Group
To delete the user and associated group:
USER="asd"
sudo deluser --remove-home "$USER"
pveum user delete "${USER}@pam" 2>/dev/null
pveum group remove admin 2>/dev/null
4. (Optional) Disable Root GUI Access
For enhanced security, disable root login for the Proxmox web GUI:
pveum user modify root@pam --enable 0
To re-enable root access to GUI:
pveum user modify root@pam --enable 1
Notes:
- Change all hardcoded credentials before using in production!
- Assigning
Administratorto a non-root user allows you to safely disable root UI access. - All commands require root/sudo privileges on your Proxmox host.