Last active
October 25, 2025 06:03
-
-
Save chris-gillatt/bfccc00cb938134879b428d8ee2e6e8c to your computer and use it in GitHub Desktop.
Set up Fedora 41, complete with a desktop environment to RDP to.
This file contains hidden or 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 -e | |
| # Define variables | |
| USER_NAME="user" | |
| RDP_PORT=3389 | |
| # Create a new password for the RDP user | |
| USER_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12}) | |
| # Check for root privileges | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "This script must be run as root." | |
| exit 1 | |
| fi | |
| # Update system packages | |
| echo "Updating system packages..." | |
| dnf update -y -q | |
| # Create the non-root user | |
| echo "Creating user '${USER_NAME}'..." | |
| useradd -m -G wheel $USER_NAME | |
| # Set user password if provided | |
| if [[ -n $USER_PASSWORD ]]; then | |
| echo "${USER_NAME}:${USER_PASSWORD}" | chpasswd | |
| else | |
| echo "No password set for ${USER_NAME}. You can set it manually using 'passwd ${USER_NAME}'." | |
| fi | |
| # Install KDE, XRDP, Firefox, and Chromium | |
| echo "Installing KDE Desktop, XRDP, Firefox, and Chromium..." | |
| dnf install -y -q @kde-desktop-environment xrdp firefox chromium | |
| # Install missing KDE components | |
| echo "Ensuring plasma-workspace-x11 is installed..." | |
| dnf install -y plasma-workspace-x11 | |
| # Enable and start XRDP | |
| echo "Enabling and starting XRDP service..." | |
| systemctl enable xrdp --now | |
| # Ensure firewalld is running before configuring | |
| echo "Ensuring FirewallD is running..." | |
| if ! systemctl is-active --quiet firewalld; then | |
| echo "Starting FirewallD service..." | |
| systemctl start firewalld | |
| systemctl enable firewalld | |
| fi | |
| # Configure the firewall to allow RDP traffic | |
| echo "Configuring the firewall to allow RDP traffic on port ${RDP_PORT}..." | |
| firewall-cmd --permanent --add-port=${RDP_PORT}/tcp | |
| firewall-cmd --reload | |
| # Print user and password for RDP | |
| echo "########" | |
| echo "RDP Username: $USER_NAME" | |
| echo "RDP Password: $USER_PASSWORD" | |
| echo ""########"" | |
| # Reboot the system | |
| echo "Setup complete. Rebooting the system..." | |
| reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment