RDP - Bash script for installing the xfce graphical interface on Ubuntu 24.04 - 2026 - ENG

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2026
Перейти к:навигация, поиск

Published: 2026-07-21

Short description: A Bash script to automatically install the XFCE desktop environment and xRDP server on a fresh Ubuntu 24.04. After execution you get a server ready for RDP connections with the XFCE desktop.

Script

#!/usr/bin/env bash

set -euo pipefail

#############################################
# Ubuntu 24.04 XFCE + xRDP Installer
#############################################

if [[ $EUID -ne 0 ]]; then
    echo "Run the script as root."
    exit 1
fi

export DEBIAN_FRONTEND=noninteractive

USERNAME="admin1"

echo "========================================"
echo " Ubuntu 24.04 XFCE + xRDP Installer"
echo "========================================"

echo
echo "[1/9] Updating system..."
apt update
apt -y upgrade

echo
echo "[2/9] Installing tasksel..."
apt install -y tasksel

echo
echo "[3/9] Installing XFCE desktop..."
if tasksel --list-tasks | grep -q "xubuntu-desktop"; then
    echo "Using tasksel..."
    tasksel install xubuntu-desktop
else
    echo "Installing XFCE directly..."
    apt install -y xfce4 xfce4-goodies
fi

echo
echo "[4/9] Installing xRDP..."
apt install -y xrdp xorgxrdp

echo
echo "[5/9] Creating user..."
if id "$USERNAME" >/dev/null 2>&1; then
    echo "User $USERNAME already exists."
else
    adduser --gecos "" "$USERNAME"
    usermod -aG sudo "$USERNAME"
fi

echo
echo "[6/9] Configuring XFCE..."
echo "startxfce4" > /etc/skel/.xsession
chmod +x /etc/skel/.xsession
cp -f /etc/skel/.xsession /home/$USERNAME/.xsession
chown $USERNAME:$USERNAME /home/$USERNAME/.xsession

echo
echo "[7/9] Configuring xRDP..."
adduser xrdp ssl-cert || true
systemctl enable xrdp
systemctl restart xrdp

echo
echo "[8/9] Firewall..."
if command -v ufw >/dev/null 2>&1; then
    ufw allow 3389/tcp || true
fi

echo
echo "[9/9] Verification..."
systemctl --no-pager --full status xrdp | head -15

IP=$(hostname -I | awk '{print $1}')

echo
echo "========================================"
echo "Installation complete!"
echo
echo "RDP:"
echo "  IP:      ${IP}"
echo "  Port:    3389"
echo "  Login:   ${USERNAME}"
echo "  Password: the one you set during user creation"
echo "========================================"

What the script does

The script performs 9 steps:

  1. System update — apt update && apt upgrade.
  2. Install tasksel — utility for installing Ubuntu meta-packages.
  3. Install XFCE — if the xubuntu-desktop meta-package is available, installs via tasksel; otherwise installs xfce4 + xfce4-goodies directly.
  4. Install xRDP — packages xrdp and xorgxrdp.
  5. Create user — creates user admin1 (if it does not exist) and adds to the sudo group.
  6. Configure XFCE — writes startxfce4 into .xsession so the desktop starts automatically on RDP connection.
  7. Configure xRDP — adds user xrdp to the ssl-cert group, enables and restarts the service.
  8. Firewall — opens port 3389/TCP in UFW (if installed).
  9. Verification — prints the xrdp service status and the server IP address.

Usage

  1. Download the script onto a clean Ubuntu 24.04.
  2. Make it executable: chmod +x script.sh
  3. Run as root: sudo ./script.sh
  4. Wait for completion.
  5. Connect with any RDP client using the server IP address, port 3389, login admin1.

Notes

  • The script is designed for Ubuntu 24.04 and may not work on other versions or distributions.
  • The password for user admin1 is set interactively during script execution (step 5).
  • If using a cloud server, make sure port 3389 is also open in the cloud provider's security group / firewall panel.
  • XFCE was chosen as a lightweight environment — minimal memory consumption and good performance over RDP.
×
Реклама
← В главную
ИКС 88x31 - Visitor counter