Complete guide to strengthen Proxmox server security by applying the principle of least privilege.
This guide allows you to:
- Create a dedicated administrator user
- Configure SSH key authentication for this user and for root
- Disable password authentication and restrict direct root access
- Integrate the new user into the Proxmox web interface with full privileges
- Initial access as
rootto your Proxmox server (via SSH or the web interface shell) - Your SSH public key (contained in a file like
~/.ssh/id_rsa.pubor~/.ssh/id_ed25519.pubon your local machine)
We create a standard user (e.g., pveadmin) who will obtain root privileges only when necessary via the sudo command.
Create the user:
# This command creates the user and their home directory /home/pveadmin
adduser pveadminFollow the instructions to set a strong password.
Add the user to the sudo group:
# This gives them the right to execute commands as root
usermod -aG sudo pveadminThis step enables secure, passwordless connection. We will add your public key to both pveadmin and root accounts.
For the pveadmin user:
# Switch to the pveadmin user
su - pveadmin
# Create the .ssh directory with proper permissions
mkdir ~/.ssh
chmod 700 ~/.ssh
# Add your public key to the authorized_keys file
# REPLACE the content in quotes with YOUR complete public key
echo "ssh-rsa AAAA... your_email@machine" >> ~/.ssh/authorized_keys
# Apply security permissions to the file
chmod 600 ~/.ssh/authorized_keys
# Return to the root session
exitFor the root user:
This is a good practice to maintain a backup key-based access.
# Make sure you're root. Create the .ssh directory if it doesn't exist.
mkdir -p /root/.ssh
chmod 700 /root/.ssh
# Add your public key to root's authorized_keys file
echo "ssh-rsa AAAA... your_email@machine" >> /root/.ssh/authorized_keys
# Apply security permissions
chmod 600 /root/.ssh/authorized_keysOpen a new terminal on your local machine and test both connections. They should connect without asking for a password.
# Connection test for pveadmin
ssh pveadmin@YOUR_PROXMOX_IP
# Connection test for root
ssh root@YOUR_PROXMOX_IPNow that key-based access is functional, we can disable less secure connection methods.
Open the SSH configuration file:
nano /etc/ssh/sshd_configModify or add the following lines:
Make sure they are not commented out (no # at the beginning).
# Authentication:
# Prohibits root login by password, but allows it via SSH key.
# This is a good compromise for Proxmox cluster management and emergency access.
# For maximum security (completely block root SSH), use 'no' instead.
PermitRootLogin prohibit-password
# Ensure that public key authentication is explicitly enabled.
PubkeyAuthentication yes
# Completely disable password authentication for all users.
# This is the most important step to prevent brute force attacks.
PasswordAuthentication noRestart the SSH service to apply the changes:
systemctl restart sshdThe pveadmin user exists on the system but not yet in Proxmox management. We will add it and grant administrator rights.
-
Log in to the Proxmox web interface as
root -
Add the user:
- Go to
Datacenter→Permissions→Users - Click on
Add - User name:
pveadmin - Realm:
Linux PAM standard authentication - Click on
Add
- Go to
-
Assign permissions:
- Go to
Datacenter→Permissions - Click on
Add→User Permission - Path:
/(the root, for the entire datacenter) - User:
pveadmin@pam - Role:
Administrator - Click on
Add
- Go to
-
Enable Two-Factor Authentication (MFA) - Recommended:
- Go to
Datacenter→Permissions→Two Factor - Select the user
pveadmin@pam - Click on
Add→TOTP - Scan the QR code with your authenticator app (Google Authenticator, Authy, Microsoft Authenticator, etc.)
- Enter the verification code from your app
- Click on
Add
Alternatively, you can configure MFA directly from the user settings:
- Go to
Datacenter→Permissions→Users - Select
pveadmin@pam - Click on
TFAbutton - Choose your preferred method (TOTP, WebAuthn, or Recovery Keys)
- Follow the setup wizard
- Go to
You can now log out of the web interface and reconnect with the pveadmin user.
- ✅ Direct SSH access with root password is blocked (key-based access still available for emergency)
- ✅ Daily SSH access is done via
pveadmin, a user with standard privileges - ✅ Administrative tasks on the command line require
sudo, ensuring better traceability - ✅ Authentication is secured by a cryptographically robust SSH key
- ✅ The new
pveadminuser has full access to the web interface, equivalent to root - ✅ Two-Factor Authentication (MFA) adds an extra layer of security to web interface access
- Always keep a copy of your SSH private key in a safe place
- Never share your SSH private key
- Use ED25519 SSH keys for optimal security:
ssh-keygen -t ed25519 -C "your_email@example.com" - Always test your SSH connections before closing your initial root session
- Enable MFA/2FA for all administrative accounts
- Store your MFA recovery codes in a secure location (password manager or encrypted storage)
Found an issue or have a suggestion? Contributions are welcome!
- Open an issue to report bugs or request features
- Submit a pull request to improve the guide
- Share your feedback and experience
This guide is provided for informational purposes. Use it at your own risk.
Note: Always ensure you have backup access to your server (physical console or KVM) before modifying SSH configuration.