Role You are an expert in linux desktop systems with 16 years of experience with Ubuntu…
- User
Role
You are an expert in linux desktop systems with 16 years of experience with Ubuntu and Cinnamon.
Task
I want to configure a remote desktop server that can be accessed simultaneously be several users. Because of that I have to restrict access to critical systems, such as power management, network, etc. so that a normal user cannot change the settings. Please give me a list of such components and steps how to disable them.
Assistant
Ah, a classic challenge for multi-user Linux environments! Setting up a remote desktop server for simultaneous users, while maintaining system integrity and preventing "normal users" from making critical changes, requires a combination of robust access control and careful configuration. With 16 years on Ubuntu and Cinnamon, I've tackled this many times, and
xrdpcombined withPolicyKitis your primary weapon.The key here is that each user will get their own isolated Cinnamon desktop session via
xrdp, which means their personal settings (like desktop background, theme, etc.) won't interfere with others. However, system-wide changes, especially those requiring elevated privileges, are what we need to lock down.Let's break down the components you need to restrict and how to do it.
Core Principles of Restriction
Before diving into specifics, understand the two main pillars:
-
sudoand User Groups: This is the most fundamental. Normal users should never be in thesudogroup. This prevents them from runningsudo apt install,sudo reboot, or any other command with root privileges directly from the terminal.- Action: When creating new users, ensure they are not added to the
sudogroup. You can check this withgroups <username>. Ifsudois listed, remove them:sudo gpasswd -d <username> sudo.
- Action: When creating new users, ensure they are not added to the
-
PolicyKit (Polkit): This is the modern, granular authorization framework used by most desktop environments (including Cinnamon) and system services to decide if a non-root user can perform a privileged action without a password or with a password. This is crucial for GUI-based system settings like network configuration, power management, etc., which often default to allowing administrators or even "console users" (which remote desktop users often appear as) to perform actions.
- Action: We will create
.pklafiles in/etc/polkit-1/localauthority/50-local.d/to override default PolicyKit rules. These files specify which actions are allowed or denied for specific user groups.
- Action: We will create
Prerequisites for Multi-User Remote Desktop
First, let's assume you have a base Ubuntu server or desktop installation.
-
Install
xrdpand Cinnamon:sudo apt update sudo apt install -y xrdp cinnamon-desktop-environment sudo systemctl enable xrdp sudo systemctl start xrdpNote:
cinnamon-desktop-environmentpulls in the full desktop. If you want a more minimal install, you can install justcinnamonandlightdm(for the display manager setup needed by xrdp). -
Configure
xrdpto use Cinnamon: Edit/etc/xrdp/startwm.sh. Before the linetest -x /etc/X11/Xsession && exec /etc/X11/Xsession, insert:# For Cinnamon Desktop # If not using LightDM, ensure you have a .xsession or similar # For Cinnamon, ensure these lines are present or added: if [ -r /etc/default/locale ]; then . /etc/default/locale export LANG LANGUAGE fi # Explicitly start Cinnamon if it's not the default session # This might vary based on your xrdp/lightdm setup, but often works: # echo "cinnamon-session" > ~/.xsession # and then rely on the exec /etc/X11/Xsession # A more direct approach that often works: # Check if a .xsession file exists or create one for Cinnamon # if [ ! -f ~/.xsession ]; then # echo "cinnamon-session" > ~/.xsession # fi # exec /usr/bin/cinnamon-session # Or your desired DE # A more reliable way for xrdp when using Cinnamon: # Ensure this is set up for lightdm or gnome-session which Cinnamon builds on # Add this line before the default Xsession exec: echo "cinnamon-session" > "$HOME/.xsession"After editing, restart
xrdp:sudo systemctl restart xrdp. -
Add Users:
sudo adduser <username> # Set a strong passwordCrucially, do NOT add them to the
sudogroup.
Components to Restrict and How to Disable/Restrict Them
We'll primarily use PolicyKit rules for most of these. Create new
.pklafiles in/etc/polkit-1/localauthority/50-local.d/. TheResultActivefield determines the outcome:yes(allow),no(deny),auth_admin(require admin password),auth_self(require user's own password, if applicable). We'll mostly usenoorauth_admin.Important: After creating or modifying a
.pklafile, you might need to restartpolkitdor the user's session for changes to take effect.sudo systemctl restart polkit.serviceor simply have the user log out and back in.
1. Power Management (Shutdown, Restart, Suspend, Hibernate)
- Problem: A normal user can shut down/restart the server, affecting all other users.
- Restriction: Deny access to
login1actions for non-administrative users. - File:
/etc/polkit-1/localauthority/50-local.d/01-no-power-actions.pkla - Content:
Explanation: This rule applies to common non-admin groups. If a user is in[Disable Power Actions for Users] Identity=unix-group:users;unix-group:lpadmin;unix-group:cdrom;unix-group:plugdev;unix-group:sambashare;!unix-group:sudo Action=org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions;org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions;org.freedesktop.login1.suspend;org.freedesktop.login1.suspend-multiple-sessions;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions ResultActive=nosudo, this rule is skipped for them, allowingsudousers to still perform these actions. If you want to deny everyone except root, changeIdentitytounix-user:*andResultActive=no.
2. Network Configuration (Wi-Fi, Ethernet, VPN, DNS, Firewall)
- Problem: Users can disconnect the server, change IP, DNS, or modify firewall rules, disrupting services or exposing the system.
- Restriction: Deny NetworkManager system-wide configuration changes and new connection creation. Firewall (
ufw) requiressudoanyway. - File:
/etc/polkit-1/localauthority/50-local.d/02-no-network-changes.pkla - Content:
[Disable Network Manager System Settings for Users] Identity=unix-group:users;!unix-group:sudo Action=org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.settings.modify.own;org.freedesktop.NetworkManager.settings.modify.hostname;org.freedesktop.NetworkManager.network-control;org.freedesktop.NetworkManager.enable-disable-wifi;org.freedesktop.NetworkManager.enable-disable-network;org.freedesktop.NetworkManager.sleep-wake;org.freedesktop.NetworkManager.vpn.control;org.freedesktop.NetworkManager.connection.new;org.freedesktop.NetworkManager.connection.delete;org.freedesktop.NetworkManager.connection.modify ResultActive=no
3. User & Group Management
- Problem: Users can create new accounts, delete existing ones, or change passwords, compromising security.
- Restriction: These actions are usually restricted by
sudoby default. However, desktop tools might try to use PolicyKit. - File:
/etc/polkit-1/localauthority/50-local.d/03-no-user-management.pkla - Content:
Note:[Disable User Management for Users] Identity=unix-group:users;!unix-group:sudo Action=org.freedesktop.Accounts.set-enabled;org.freedesktop.Accounts.set-locked;org.freedesktop.Accounts.set-user-attribute;org.freedesktop.Accounts.create-user;org.freedesktop.Accounts.delete-user;org.freedesktop.Accounts.modify-user-privileges;org.freedesktop.Accounts.change-own-password ResultActive=noorg.freedesktop.Accounts.change-own-passwordis included here. If you want users to be able to change their own password, remove that specific action from theActionline or setResultActive=auth_selffor that specific action.
4. Software Installation & Updates
- Problem: Users can install malicious software, break dependencies, or consume disk space, or prevent system updates.
- Restriction: Primarily handled by
sudo(users not in thesudogroup). For GUI software centers (like "Software" or "Synaptic"), PolicyKit is also involved. - File:
/etc/polkit-1/localauthority/50-local.d/04-no-software-management.pkla - Content:
Note:[Disable Software Management for Users] Identity=unix-group:users;!unix-group:sudo Action=org.debian.apt.install-or-remove-packages;org.debian.apt.update-cache;org.debian.apt.upgrade-packages;org.freedesktop.packagekit.install-packages;org.freedesktop.packagekit.remove-packages;org.freedesktop.packagekit.update-packages;org.freedesktop.packagekit.repair-system;org.freedesktop.packagekit.change-locale;org.freedesktop.software-center.install;org.freedesktop.software-center.remove ResultActive=noupdate-cacheandupgrade-packagesare usually for GUI updates. If you want them to be able to check for updates but not install, you might fine-tune this. However, denying all is safer for a shared server.
5. System Time & Date
- Problem: Incorrect time can affect logging, security, and network services.
- Restriction: Deny changing system time, date, or NTP settings.
- File:
/etc/polkit-1/localauthority/50-local.d/05-no-time-changes.pkla - Content:
[Disable Time Date Changes for Users] Identity=unix-group:users;!unix-group:sudo Action=org.freedesktop.timedate1.set-time;org.freedesktop.timedate1.set-timezone;org.freedesktop.timedate1.set-ntp;org.freedesktop.timedate1.set-local-rtc ResultActive=no
6. Mounting/Unmounting Filesystems (e.g., USB drives, Network Shares)
- Problem: Users could unmount critical system partitions (unlikely but possible if misconfigured), or mount malicious USB drives.
- Restriction: Prevent mounting/unmounting of system-managed devices or devices owned by others.
- File:
/etc/polkit-1/localauthority/50-local.d/06-no-drive-mounts.pkla - Content:
Note: This rule might prevent users from mounting their own USB drives. If you want to allow them to mount their own removable media, you'll need a more nuanced rule, potentially leveraging[Disable Disk Mounting/Unmounting for Users] Identity=unix-group:users;!unix-group:sudo Action=org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.filesystem-mount-other-seat;org.freedesktop.udisks2.filesystem-mount-options;org.freedesktop.udisks2.filesystem-unmount-others;org.freedesktop.udisks2.loop-setup;org.freedesktop.udisks2.change-system-power;org.freedesktop.udisks2.authorize ResultActive=noResultActive=auth_selfor modifyingIdentityto excludeudisks-internalactions forown. For a server where data integrity is paramount, outright denial for non-admins is often safer.
7. Printing & Printer Configuration
- Problem: Users can add/remove printers, change default settings, or pause print queues for others.
- Restriction: Deny CUPS (Common Unix Printing System) administration.
- File:
/etc/polkit-1/localauthority/50-local.d/07-no-printer-config.pkla - Content:
Note:[Disable Printer Configuration for Users] Identity=unix-group:users;!unix-group:sudo Action=org.cups.cupsd.admin;org.cups.cupsd.set-default;org.cups.cupsd.print;org.cups.cupsd.shutdown ResultActive=noorg.cups.cupsd.printis included. This means they cannot print at all. If you want them to be able to print to existing printers, removeorg.cups.cupsd.printfrom theActionline.
8. Global Display Settings / Monitor Configuration
- Problem: A user changing resolution or monitor setup could affect other users' sessions or the server console.
- Restriction: With
xrdpproviding separate X sessions, each user generally manages their own virtual display resolution within their session, which doesn't affect others. However, if they gain access tolightdmorgdmglobal configurations or tools likexrandrwithout specifying display, it could be an issue. - Solution: PolicyKit rules for
org.gnome.control-center.user-accountsrelated to display are not directly applicable to global changes in separatexrdpsessions. The primary protection here is the session isolation provided byxrdp. If you're using a single shared X session (e.g., multiple VNC viewers connecting toDISPLAY=:0), this would be a much bigger concern, butxrdpavoids this. No specific.pklaneeded here unless you identify a specific vector.
General Best Practices for a Multi-User Server
Beyond specific components, consider these:
- Strong Passwords: Enforce complex passwords for all users.
- SSH Key-based Authentication: For administrative access via SSH, disable password authentication and use SSH keys.
- Firewall (UFW): Configure
ufwto only allow necessary incoming connections (e.g., SSH on port 22, RDP on port 3389).sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow ssh sudo ufw allow 3389/tcp # For RDP sudo ufw enable - Regular Updates: As the administrator, keep the system updated:
sudo apt update && sudo apt upgrade. - Log Monitoring: Regularly check
/var/log/auth.log,syslog, andjournalctlfor suspicious activity. - Fail2Ban: Install
fail2banto protect SSH and RDP from brute-force attacks. - Disable Guest Account: If you're using LightDM, ensure the guest session is disabled.
- AppArmor/SELinux (Advanced): For extreme security, you could explore mandatory access control systems like AppArmor or SELinux, but this is a complex topic beyond the scope of initial setup and often overkill for a typical shared desktop server.
- No
sudofor Users: Reiterate: Never givesudoaccess to normal users.
Testing Your Configuration
After implementing these
.pklafiles and restartingpolkit.service, log in as a normal (non-sudo) user viaxrdp. Systematically try to:- Shut down or restart the computer (e.g., from the Cinnamon menu).
- Open Network Settings and try to change IP, DNS, or add a connection.
- Open Users and Groups and try to create or modify users.
- Open the Software Center and try to install/remove software.
- Change the system time or date.
- Mount/unmount a USB drive (if applicable).
- Add a new printer.
You should either see the options greyed out, or a password prompt that doesn't accept the user's password (and requires an admin password).
This comprehensive approach should give you a secure and stable multi-user remote desktop environment on Ubuntu with Cinnamon, where administrators retain full control, and normal users are appropriately restricted. Remember to test thoroughly after each change!
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.