<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: VPS Shell</title>
    <description>The latest articles on DEV Community by VPS Shell (@vps_shell_697726dc9d6a166).</description>
    <link>https://dev.to/vps_shell_697726dc9d6a166</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4259588%2F2d02a5bc-4edb-425e-a97d-c3b41ab318b3.png</url>
      <title>DEV Community: VPS Shell</title>
      <link>https://dev.to/vps_shell_697726dc9d6a166</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vps_shell_697726dc9d6a166"/>
    <language>en</language>
    <item>
      <title>Setting Up a New Debian VPS: The First Things to Do (Debian 13 Edition)</title>
      <dc:creator>VPS Shell</dc:creator>
      <pubDate>Mon, 23 Nov 2026 03:01:05 +0000</pubDate>
      <link>https://dev.to/vps_shell_697726dc9d6a166/setting-up-a-new-debian-vps-the-first-things-to-do-debian-13-edition-1nn</link>
      <guid>https://dev.to/vps_shell_697726dc9d6a166/setting-up-a-new-debian-vps-the-first-things-to-do-debian-13-edition-1nn</guid>
      <description>&lt;p&gt;A fresh Debian server is quiet, fast and almost empty. That is the point, but it also means the first 20 minutes decide whether it stays a clean, safe machine or turns into the box that got brute-forced over the weekend.&lt;/p&gt;

&lt;p&gt;This is the checklist I run on every new Debian VPS, written for &lt;strong&gt;Debian 13 (trixie)&lt;/strong&gt;, the current stable release. Most of it applies to Debian 12 as well, and I call out the places where trixie behaves differently, because a few of those changes catch people out on small servers.&lt;/p&gt;

&lt;p&gt;It assumes a plain Debian image on a KVM VPS with root access, the kind you get from most providers, including &lt;a href="https://www.vpsshell.com/" rel="noopener noreferrer"&gt;VPS Shell&lt;/a&gt;. Nothing here depends on a specific host.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Look at what you actually got
&lt;/h2&gt;

&lt;p&gt;Before changing anything, spend 30 seconds confirming the basics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat /etc/debian_version
hostnamectl
free -h
df -h /
ip -br a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You want to see the Debian version you ordered, the RAM and disk you paid for, and your public IP on the main interface. If any of that is off, raise it with your provider now, not after you have deployed an app.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Update everything, then reboot once
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt update
apt full-upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Provider images are often a few weeks old. If the upgrade pulled in a new kernel, reboot so you are actually running it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doing this on day one is painless. Doing it later, with services running, is the reboot everyone keeps postponing.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Hostname, time zone and time sync
&lt;/h2&gt;

&lt;p&gt;Give the machine a name you will recognise in logs and prompts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hostnamectl set-hostname web-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the time zone. Many people keep servers on UTC so logs line up across machines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;timedatectl set-timezone UTC
timedatectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check that &lt;code&gt;System clock synchronized&lt;/code&gt; says &lt;code&gt;yes&lt;/code&gt;. Some minimal images ship without a time sync service. If it says &lt;code&gt;no&lt;/code&gt;, install the lightweight one Debian provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt install -y systemd-timesyncd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrong time breaks TLS, two-factor codes and log correlation in confusing ways, so this is worth getting right early.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Fix locale warnings before they annoy you
&lt;/h2&gt;

&lt;p&gt;If you SSH in from a Mac or a desktop set to another language, you may see &lt;code&gt;setlocale&lt;/code&gt; warnings on every command. Generate the locale your client sends, or set a sensible default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dpkg-reconfigure locales
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pick &lt;code&gt;en_US.UTF-8&lt;/code&gt; (plus any locale you actually use) and set it as the default.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Create your own user with sudo
&lt;/h2&gt;

&lt;p&gt;Working as root all the time makes every typo a full-power typo. Minimal Debian images do not always include sudo, so install it first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt install -y sudo
adduser alex
usermod -aG sudo alex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open a &lt;strong&gt;second&lt;/strong&gt; terminal and confirm you can log in as that user and run &lt;code&gt;sudo whoami&lt;/code&gt; before you go further. Keep your root session open until then.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Switch SSH to keys only
&lt;/h2&gt;

&lt;p&gt;On your own computer, create a modern key if you do not have one. Ed25519 is short, fast and widely supported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen -t ed25519 -C &lt;span class="s2"&gt;"alex@laptop"&lt;/span&gt;
ssh-copy-id alex@YOUR_SERVER_IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One Debian 13 detail: OpenSSH in trixie has dropped DSA completely. According to the release notes, as of OpenSSH 9.8p1 in trixie, DSA keys are no longer supported even with the old compatibility options. If you still have an ancient &lt;code&gt;id_dsa&lt;/code&gt; key somewhere, replace it now.&lt;/p&gt;

&lt;p&gt;Rather than editing the main config file, put your changes in a drop-in file, which survives package upgrades cleanly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo nano /etc/ssh/sshd_config.d/10-hardening.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the configuration before applying it, then reload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo sshd -t &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo systemctl reload ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the service is called &lt;code&gt;ssh&lt;/code&gt; on Debian, not &lt;code&gt;sshd&lt;/code&gt;. Now, &lt;strong&gt;without closing your current session&lt;/strong&gt;, open a new terminal and log in with your key. Only close the old session once the new one works. This one habit prevents most self-inflicted lockouts.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Turn on a simple firewall
&lt;/h2&gt;

&lt;p&gt;Debian uses nftables under the hood, but for a single server &lt;code&gt;ufw&lt;/code&gt; is the easiest way to get a safe default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
sudo ufw status verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order matters: allow SSH &lt;strong&gt;before&lt;/strong&gt; you enable the firewall. Add web ports only when you actually run a web server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ufw allow 80,443/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. Let security updates install themselves
&lt;/h2&gt;

&lt;p&gt;Most servers are not compromised through clever zero-days. They are compromised through old, known bugs that a routine update would have fixed. Debian's &lt;code&gt;unattended-upgrades&lt;/code&gt; handles security updates on its own:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install -y unattended-upgrades apt-listchanges
sudo dpkg-reconfigure -plow unattended-upgrades
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Answer yes. By default it only installs updates from the security archive, which is the safe choice for a server. Check that it would do something sensible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo unattended-upgrade --dry-run --debug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. Add swap on small servers
&lt;/h2&gt;

&lt;p&gt;A 1 GB or 2 GB VPS with no swap will eventually meet the out-of-memory killer, usually during a package upgrade or a build. A small swap file gives you breathing room:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'/swapfile none swap sw 0 0'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sudo tee -a /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tell the kernel to prefer RAM and use swap only when it has to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'vm.swappiness=10'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. Know the Debian 13 changes that surprise people
&lt;/h2&gt;

&lt;p&gt;A few trixie changes are harmless on a laptop but matter on a small server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/tmp now lives in RAM.&lt;/strong&gt; On trixie, the default is for the /tmp directory to be stored in memory, and up to 50% of memory can be allocated to it. On a 1 GB VPS, a big upload or a build that writes large temp files can eat into the memory your apps need. If that is a problem, cap it with &lt;code&gt;sudo systemctl edit tmp.mount&lt;/code&gt; and set a size in the options, for example &lt;code&gt;Options=mode=1777,nosuid,nodev,size=256M&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/tmp and /var/tmp are cleaned automatically.&lt;/strong&gt; Files in /tmp are now deleted after 10 days from the time they were last used, and after a reboot. Files in /var/tmp are deleted after 30 days, but not after a reboot. Never keep anything you care about in either place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;last&lt;/code&gt; and &lt;code&gt;lastlog&lt;/code&gt; are gone.&lt;/strong&gt; util-linux no longer provides the &lt;code&gt;last&lt;/code&gt; or &lt;code&gt;lastb&lt;/code&gt; commands, and the login package no longer provides &lt;code&gt;lastlog&lt;/code&gt;. If you rely on them to check who logged in, install the replacements: &lt;code&gt;wtmpdb&lt;/code&gt; (with libpam-wtmpdb) replaces &lt;code&gt;last&lt;/code&gt;, and &lt;code&gt;lastlog2&lt;/code&gt; (with libpam-lastlog2) replaces &lt;code&gt;lastlog&lt;/code&gt;. For failed logins, &lt;code&gt;lslogins --failed&lt;/code&gt; gives similar information to &lt;code&gt;lastb&lt;/code&gt;. And &lt;code&gt;journalctl -u ssh&lt;/code&gt; always works.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Optional: fail2ban, configured for the journal
&lt;/h2&gt;

&lt;p&gt;With password logins disabled, brute-force attempts cannot succeed, but they still fill your logs. fail2ban bans noisy IPs. On recent Debian, SSH logs go to the systemd journal rather than a text file, so tell fail2ban to read the journal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install -y fail2ban
sudo nano /etc/fail2ban/jail.d/sshd.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="k"&gt;[sshd]&lt;/span&gt;
&lt;span class="na"&gt;enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;backend&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;systemd&lt;/span&gt;
&lt;span class="na"&gt;maxretry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="na"&gt;bantime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart fail2ban
sudo fail2ban-client status sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If fail2ban fails to start complaining about a missing log file, the &lt;code&gt;backend = systemd&lt;/code&gt; line is usually what is missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Take a snapshot before you build anything
&lt;/h2&gt;

&lt;p&gt;You now have a clean, updated, locked-down base. If your provider offers snapshots or backups, take one now. It is the fastest way back to a known-good server if an experiment goes wrong later.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 20-minute checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Confirm Debian version, RAM, disk and IP&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;apt full-upgrade&lt;/code&gt;, reboot once&lt;/li&gt;
&lt;li&gt;Hostname, time zone, time sync&lt;/li&gt;
&lt;li&gt;Locale set, no &lt;code&gt;setlocale&lt;/code&gt; warnings&lt;/li&gt;
&lt;li&gt;Personal user with sudo, root login disabled&lt;/li&gt;
&lt;li&gt;SSH keys only, config in &lt;code&gt;sshd_config.d&lt;/code&gt;, tested before closing your session&lt;/li&gt;
&lt;li&gt;ufw on, SSH allowed first&lt;/li&gt;
&lt;li&gt;unattended-upgrades for security updates&lt;/li&gt;
&lt;li&gt;Swap on small servers&lt;/li&gt;
&lt;li&gt;Aware of tmpfs &lt;code&gt;/tmp&lt;/code&gt;, auto-cleaning, and the &lt;code&gt;last&lt;/code&gt; replacements&lt;/li&gt;
&lt;li&gt;fail2ban with &lt;code&gt;backend = systemd&lt;/code&gt; if you want quieter logs&lt;/li&gt;
&lt;li&gt;Snapshot taken&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is the whole routine. It is not exotic, and that is exactly why it works: a server that is updated, key-only and firewalled already avoids the vast majority of trouble that new VPS owners run into. If you do something different on your own first boot, I would like to hear about it in the comments.&lt;/p&gt;

</description>
      <category>debian</category>
      <category>linux</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>A Remote Linux Desktop That Actually Works: XFCE + xrdp on Ubuntu 24.04 (and the Firefox Snap Trap)</title>
      <dc:creator>VPS Shell</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:54:08 +0000</pubDate>
      <link>https://dev.to/vps_shell_697726dc9d6a166/a-remote-linux-desktop-that-actually-works-xfce-xrdp-on-ubuntu-2404-and-the-firefox-snap-trap-2adb</link>
      <guid>https://dev.to/vps_shell_697726dc9d6a166/a-remote-linux-desktop-that-actually-works-xfce-xrdp-on-ubuntu-2404-and-the-firefox-snap-trap-2adb</guid>
      <description>&lt;p&gt;You spin up a fresh Ubuntu 24.04 server, install a desktop, connect with Remote Desktop and get one of three things: a black screen, a session that closes the second you log in, or a desktop where Firefox simply refuses to open.&lt;/p&gt;

&lt;p&gt;This guide gets you a light, usable remote desktop on a cloud server and fixes those three problems on purpose, instead of leaving you to search for them later. It uses XFCE because it is fast over RDP, and xrdp because it works with the Remote Desktop client already built into Windows, plus Microsoft's free app on macOS, iOS and Android.&lt;/p&gt;

&lt;p&gt;Everything here was written for Ubuntu 24.04 LTS on a KVM virtual server. It also works on Debian 12 with small changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  When a desktop on a server makes sense
&lt;/h2&gt;

&lt;p&gt;Most servers should stay headless. A desktop is worth it when you need a real browser on a remote network (testing geo-targeted pages, logging into dashboards from a fixed IP), a GUI-only tool, a long-running app you want to check on visually, or a remote workspace you can reach from any device.&lt;/p&gt;

&lt;p&gt;Sizing matters more than people expect. The desktop itself is small, but a modern browser is not. Plan for &lt;strong&gt;2 GB of RAM as a practical minimum&lt;/strong&gt; for one user with a browser, and 4 GB if you keep several tabs open or more than one person connects. One vCPU works, two feels much smoother.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: create a normal user for the desktop
&lt;/h2&gt;

&lt;p&gt;Do not run your desktop session as root. Several desktop components refuse to start or behave oddly as root, and a browser running as root is a bad idea anyway.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo adduser deskuser
sudo usermod -aG sudo deskuser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this account for everything below that says "as your desktop user".&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: install XFCE without the extras you do not need
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
sudo apt install -y xfce4 xfce4-goodies dbus-x11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two notes on that line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;dbus-x11&lt;/strong&gt; is the piece people forget. Without it, XFCE often starts with an error about not reaching the settings server, and panels or settings go missing.&lt;/li&gt;
&lt;li&gt;When the installer asks you to pick a display manager, choose &lt;strong&gt;lightdm&lt;/strong&gt; or just accept the default. xrdp does not use it, so the choice does not matter for remote sessions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: install xrdp and point it at XFCE
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install -y xrdp
sudo adduser xrdp ssl-cert
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ssl-cert&lt;/code&gt; group gives xrdp read access to the system certificate it uses to encrypt the connection. Skip it and you can get a login that fails right after you type your password.&lt;/p&gt;

&lt;p&gt;Now tell xrdp which desktop to start. As your desktop user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"xfce4-session"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.xsession
chmod +x ~/.xsession
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then restart the service and make sure it is listening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart xrdp
sudo ss -ltnp &lt;span class="o"&gt;|&lt;/span&gt; grep 3389
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see xrdp on port 3389.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: do not open port 3389 to the internet
&lt;/h2&gt;

&lt;p&gt;This is the step most tutorials get wrong. They tell you to run &lt;code&gt;ufw allow 3389&lt;/code&gt; and move on. Port 3389 is one of the most scanned ports on the internet, and a desktop login exposed to the world will see password guessing within hours.&lt;/p&gt;

&lt;p&gt;The better pattern is to keep 3389 closed and reach it through SSH, which you already have.&lt;/p&gt;

&lt;p&gt;On the server, make sure only SSH is allowed in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ufw allow OpenSSH
sudo ufw &lt;span class="nb"&gt;enable&lt;/span&gt;
sudo ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do not add a rule for 3389.&lt;/p&gt;

&lt;p&gt;On your own computer, open a tunnel. Using local port 13389 avoids clashing with a Remote Desktop service that may already run on your own machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh -L 13389:localhost:3389 deskuser@YOUR_SERVER_IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leave that window open, then connect your Remote Desktop client to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localhost:13389
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Log in with your desktop user. Your whole session now travels inside SSH, and nothing new is exposed. If you use SSH keys, you also get key-based protection in front of the desktop for free.&lt;/p&gt;

&lt;p&gt;On Windows, the same &lt;code&gt;ssh&lt;/code&gt; command works in PowerShell or Windows Terminal, since OpenSSH is built in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: the Firefox snap trap, and how to get a browser that works
&lt;/h2&gt;

&lt;p&gt;Here is the one that wastes the most time. On Ubuntu 24.04, &lt;code&gt;sudo apt install firefox&lt;/code&gt; does not install a normal package. It installs a small transitional package that pulls in the &lt;strong&gt;Firefox snap&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Inside an xrdp session, the snap version often fails to start, sometimes with an error mentioning a "snap cgroup", sometimes with nothing at all except a window that never appears. The cause is how snap confinement tracks the session, not anything you did wrong.&lt;/p&gt;

&lt;p&gt;The clean fix is to use Mozilla's own APT repository, which gives you a regular .deb package that updates through apt.&lt;/p&gt;

&lt;p&gt;Remove the snap if it is installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo snap remove firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add Mozilla's signing key and repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo install -d -m 0755 /etc/apt/keyrings
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- &lt;span class="o"&gt;|&lt;/span&gt; sudo tee /etc/apt/keyrings/packages.mozilla.org.asc &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sudo tee /etc/apt/sources.list.d/mozilla.list &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tell apt to prefer Mozilla's package over Ubuntu's snap wrapper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sudo tee /etc/apt/preferences.d/mozilla
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
sudo apt install -y firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check you got the real package and not the snap again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt policy firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The installed version should come from &lt;code&gt;packages.mozilla.org&lt;/code&gt;. Firefox now opens normally inside your remote session. The same idea applies to Chromium, which is also a snap on Ubuntu; Google Chrome's own .deb is the simplest alternative there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: make it feel fast
&lt;/h2&gt;

&lt;p&gt;RDP sends screen changes over the network, so anything that animates or redraws a lot makes the session feel slow. Three changes make a visible difference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Turn off the window compositor.&lt;/strong&gt; In XFCE, open Settings, then Window Manager Tweaks, then the Compositor tab, and untick "Enable display compositing". Or from a terminal inside the session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;xfconf-query -c xfwm4 -p /general/use_compositing -s &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use a plain background.&lt;/strong&gt; A solid color compresses far better than a photo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Match your client settings to your connection.&lt;/strong&gt; In the Windows Remote Desktop client, under Show Options, then Experience, pick your real connection speed instead of "Detect automatically" if the session feels laggy, and lower the color depth on slow links.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: stop forgotten sessions from eating memory
&lt;/h2&gt;

&lt;p&gt;By default, if you close the Remote Desktop window instead of logging out, your session keeps running on the server, browser and all. Do that a few times and you run out of RAM.&lt;/p&gt;

&lt;p&gt;You can tell xrdp to clean up sessions that stay disconnected. Edit &lt;code&gt;/etc/xrdp/sesman.ini&lt;/code&gt; and, in the &lt;code&gt;[Sessions]&lt;/code&gt; section, set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="na"&gt;KillDisconnected&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;DisconnectedTimeLimit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3600&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That ends a session one hour after it is disconnected. Restart xrdp afterwards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart xrdp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you prefer to keep long-running apps alive between connections, leave this off and simply log out properly when you are done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting the three classic failures
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Black screen after login.&lt;/strong&gt; Check &lt;code&gt;~/.xsession&lt;/code&gt; exists in the home folder of the user you log in as, contains &lt;code&gt;xfce4-session&lt;/code&gt;, and is executable. Then look at the session log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat ~/.xsession-errors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Session closes immediately after login.&lt;/strong&gt; This usually means the desktop failed to start. Confirm &lt;code&gt;dbus-x11&lt;/code&gt; is installed, and check the xrdp logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u xrdp -u xrdp-sesman --since &lt;span class="s2"&gt;"10 min ago"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A related cause is a desktop session for the same user already running elsewhere. Log that session out, or use a separate user for remote access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repeated "Authentication required" pop-ups.&lt;/strong&gt; On some installs, a color management service asks for a password every time you log in over RDP. You can allow it for normal users with a small polkit rule. Create &lt;code&gt;/etc/polkit-1/rules.d/45-allow-colord.rules&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;polkit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addRule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"org.freedesktop.color-manager."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
        &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInGroup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"users"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;polkit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;YES&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then make sure your desktop user is in the &lt;code&gt;users&lt;/code&gt; group (&lt;code&gt;groups deskuser&lt;/code&gt;) and log in again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Desktop runs as a normal user, not root&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;xfce4&lt;/code&gt;, &lt;code&gt;dbus-x11&lt;/code&gt; and &lt;code&gt;xrdp&lt;/code&gt; installed, xrdp in &lt;code&gt;ssl-cert&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.xsession&lt;/code&gt; starts &lt;code&gt;xfce4-session&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Port 3389 closed, access through an SSH tunnel&lt;/li&gt;
&lt;li&gt;Firefox from Mozilla's APT repo, not the snap&lt;/li&gt;
&lt;li&gt;Compositor off, plain background&lt;/li&gt;
&lt;li&gt;Disconnected sessions cleaned up, or you log out properly&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Going further
&lt;/h2&gt;

&lt;p&gt;If you are on AlmaLinux or Rocky Linux instead of Ubuntu, or you would rather use VNC than RDP, I keep a shorter reference that covers both, along with security habits for desktops on servers: &lt;a href="https://www.vpsshell.com/kb/install-xfce-on-a-linux-vps-xrdp-or-vnc/" rel="noopener noreferrer"&gt;install XFCE on a Linux VPS with xrdp or VNC&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With these steps you get a remote desktop that starts every time, opens a browser on the first try, stays responsive on an ordinary connection and does not put a login screen on the open internet. If you hit a problem that is not covered here, leave a comment with your Ubuntu version and the last lines of &lt;code&gt;~/.xsession-errors&lt;/code&gt;, and I will take a look.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
