<?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 Lane</title>
    <description>The latest articles on DEV Community by VPS Lane (@vpslane).</description>
    <link>https://dev.to/vpslane</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%2F4267850%2F560f88ed-6257-4ef2-adc4-1c10f1c36db8.png</url>
      <title>DEV Community: VPS Lane</title>
      <link>https://dev.to/vpslane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vpslane"/>
    <language>en</language>
    <item>
      <title>Setting up a new Debian VPS: the first things to do</title>
      <dc:creator>VPS Lane</dc:creator>
      <pubDate>Thu, 26 Nov 2026 23:54:04 +0000</pubDate>
      <link>https://dev.to/vpslane/setting-up-a-new-debian-vps-the-first-things-to-do-37f7</link>
      <guid>https://dev.to/vpslane/setting-up-a-new-debian-vps-the-first-things-to-do-37f7</guid>
      <description>&lt;p&gt;A fresh Debian server is quiet, small and ready for almost anything. It is also reachable by every scanner on the internet from the minute it boots. The first half hour decides whether the box stays boring or turns into a cleanup job.&lt;/p&gt;

&lt;p&gt;This is the routine I run on every new Debian 12 or 13 VPS before I install a single app. Every step is plain Debian, so it works the same on any provider.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Log in and update everything
&lt;/h2&gt;

&lt;p&gt;Your provider gives you an IP address and a root password or an SSH key. Log in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh root@203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then bring the package list and every installed package up to date:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If the upgrade pulled in a new kernel, reboot now rather than later:&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="o"&gt;[&lt;/span&gt; -f /var/run/reboot-required &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Set the hostname and time zone
&lt;/h2&gt;

&lt;p&gt;A clear hostname saves confusion once you run more than one server.&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
timedatectl set-timezone UTC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I keep servers on UTC. Logs from several machines line up, and nothing shifts when daylight saving changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Create a normal user with sudo
&lt;/h2&gt;

&lt;p&gt;Working as root all day means one typo can wipe the system. Make a regular user and give it sudo:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Copy your SSH key to the new user
&lt;/h2&gt;

&lt;p&gt;From your own computer, not the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id deploy@203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No key yet? Make one first with &lt;code&gt;ssh-keygen -t ed25519&lt;/code&gt;. Then open a second terminal and confirm you can log in as &lt;code&gt;deploy&lt;/code&gt; with the key before you touch the SSH settings. Keep the first session open as a safety net.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Lock down SSH
&lt;/h2&gt;

&lt;p&gt;On Debian, the cleanest way to change SSH settings is a drop-in file, so package updates never overwrite your edits:&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;p&gt;Put this inside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ssh"&gt;&lt;code&gt;&lt;span class="nc"&gt;PermitRootLogin&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;
&lt;span class="nc"&gt;PasswordAuthentication&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;
&lt;span class="nc"&gt;KbdInteractiveAuthentication&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the syntax, then restart the service:&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 restart ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test a fresh login from another terminal before you close the old one. If something is wrong, you still have a way back in.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Turn on a firewall
&lt;/h2&gt;

&lt;p&gt;Debian does not enable a firewall by default. UFW is the simplest option:&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 ufw -y
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;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open only what you need later, for example &lt;code&gt;sudo ufw allow 80,443/tcp&lt;/code&gt; for a web server. Check the result with &lt;code&gt;sudo ufw status verbose&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Add fail2ban for repeated login attempts
&lt;/h2&gt;

&lt;p&gt;Key-only SSH already stops password guessing, but fail2ban keeps the logs clean and slows down noisy scanners:&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 fail2ban -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On recent Debian releases the logs live in the systemd journal, so tell the SSH jail to read from there:&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/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;h2&gt;
  
  
  8. Install security updates automatically
&lt;/h2&gt;

&lt;p&gt;Security fixes should not wait for you to remember them:&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 unattended-upgrades -y
sudo dpkg-reconfigure -plow unattended-upgrades
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Answer yes. Debian will now install security updates on its own every day. Kernel updates still need a reboot, so glance at &lt;code&gt;/var/run/reboot-required&lt;/code&gt; once a week.&lt;/p&gt;

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

&lt;p&gt;A 1 GB or 2 GB VPS can run out of memory during a big &lt;code&gt;apt&lt;/code&gt; run or a build. A small swap file stops the out-of-memory killer from ending your process:&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;Lower how eagerly the kernel swaps so RAM is still used first:&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-swap.conf
sudo sysctl --system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. Install the few tools you will want anyway
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install curl wget git htop ncdu ca-certificates -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;htop&lt;/code&gt; shows what is using CPU and RAM. &lt;code&gt;ncdu&lt;/code&gt; shows what is filling the disk, which is the most common reason a small server falls over.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Plan backups before you need them
&lt;/h2&gt;

&lt;p&gt;A snapshot from your provider is good, but it lives with the same provider. Keep at least one copy somewhere else. For files and databases, &lt;code&gt;restic&lt;/code&gt; or &lt;code&gt;borg&lt;/code&gt; sent to object storage works well and only stores changes after the first run.&lt;/p&gt;

&lt;p&gt;Write down how to restore, then try it once. A backup you have never restored is a guess.&lt;/p&gt;

&lt;h2&gt;
  
  
  A short checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;System updated and rebooted&lt;/li&gt;
&lt;li&gt;Hostname and UTC time zone set&lt;/li&gt;
&lt;li&gt;Regular sudo user with an SSH key&lt;/li&gt;
&lt;li&gt;Root login and passwords off for SSH&lt;/li&gt;
&lt;li&gt;UFW on with only SSH open&lt;/li&gt;
&lt;li&gt;fail2ban watching SSH&lt;/li&gt;
&lt;li&gt;Security updates installing themselves&lt;/li&gt;
&lt;li&gt;Swap on small plans&lt;/li&gt;
&lt;li&gt;Backups that leave the server, and one test restore&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is roughly twenty minutes of work, and the server is now in better shape than most machines on the internet. From here, install your web server, database or containers with a clean conscience.&lt;/p&gt;

&lt;p&gt;If you still need a box to practise on, a small &lt;a href="https://vpslane.com/linux-vps/" rel="noopener noreferrer"&gt;Linux VPS&lt;/a&gt; with Debian and full root access is enough for every step above.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>debian</category>
      <category>devops</category>
      <category>security</category>
    </item>
  </channel>
</rss>
