<?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: Alex</title>
    <description>The latest articles on DEV Community by Alex (@arciveo).</description>
    <link>https://dev.to/arciveo</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%2F4258668%2Fad2731f4-b4bc-40c4-8591-6df487ab7f47.png</url>
      <title>DEV Community: Alex</title>
      <link>https://dev.to/arciveo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arciveo"/>
    <language>en</language>
    <item>
      <title>A new VPS: what to do in the first hour</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Tue, 24 Nov 2026 15:00:00 +0000</pubDate>
      <link>https://dev.to/arciveo/a-new-vps-what-to-do-in-the-first-hour-1k5h</link>
      <guid>https://dev.to/arciveo/a-new-vps-what-to-do-in-the-first-hour-1k5h</guid>
      <description>&lt;p&gt;The server is up, and the email holds a root login and a password. From that moment it is visible to the whole internet: the first attempts to guess the SSH password arrive within the hour, and they arrive not because somebody heard about your site, but because hosting address ranges are swept in order, around the clock.&lt;/p&gt;

&lt;p&gt;Below are six steps that cover the essentials. Each takes a couple of minutes, and each comes with a check: a command that shows the step actually worked rather than merely ran without errors. That is the difference between "set up" and "thought it was set up". The whole sequence assumes a fresh Debian or Ubuntu.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1. Update the system
&lt;/h2&gt;

&lt;p&gt;The image the server was built from was assembled months ago. Everything out of date in it is already described in public vulnerability lists:&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 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The check:&lt;/strong&gt; running &lt;code&gt;apt list --upgradable&lt;/code&gt; again should print nothing but the &lt;code&gt;Listing...&lt;/code&gt; line. If the file &lt;code&gt;/var/run/reboot-required&lt;/code&gt; has appeared, the kernel was updated and a reboot is needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l /var/run/reboot-required
sudo reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reboot at a moment when console access in the hosting panel is within reach, in case the machine does not come back up on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2. Create your own user
&lt;/h2&gt;

&lt;p&gt;Working as root is awkward and dangerous: any typo runs without being questioned. What you need is an ordinary user able to raise privileges when required:&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 alex
sudo usermod -aG sudo alex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The check:&lt;/strong&gt; log in as that user and confirm sudo works. Do this &lt;em&gt;before&lt;/em&gt; root login is closed off:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;su - alex
sudo -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command will ask for a password and finish silently — that is success. The answer "is not in the sudoers file" means the group has not taken effect: leave the session and log in again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3. Log in with a key, not a password
&lt;/h2&gt;

&lt;p&gt;A password can be guessed, a key cannot. On your own computer, not on 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-keygen -t ed25519
ssh-copy-id alex@203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key-based login should now work without a password. Once you are sure of that, password login can be turned off in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;:&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="nc"&gt;PasswordAuthentication&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;
&lt;span class="nc"&gt;PermitRootLogin&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The check, and here it matters most of all.&lt;/strong&gt; Do not close your current connection. First make sure there is no mistake in the configuration, 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
sudo systemctl reload ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, leaving the old window open, open a second one and log in again. If the login goes through, all is well. If it does not, you still have a working session in which the setting can be put back. A single session closed with a typo in the configuration means a trip to the hosting console.&lt;/p&gt;

&lt;p&gt;One separate subtlety: files in &lt;code&gt;/etc/ssh/sshd_config.d/&lt;/code&gt; are included in alphabetical order, and the value that takes effect is the one encountered first. Images from cloud providers often carry a &lt;code&gt;50-cloud-init.conf&lt;/code&gt; there that allows passwords. That is why your own file is given a lower number, say &lt;code&gt;10-hardening.conf&lt;/code&gt;, or the edit achieves nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4. Close everything else with a firewall
&lt;/h2&gt;

&lt;p&gt;On a fresh system usually only SSH faces outward, but install a web server or a database and ports open by themselves. The rule is simple: everything is forbidden except what is allowed explicitly.&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;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In that order. Enable the firewall without allowing SSH and the connection drops on the next command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The check:&lt;/strong&gt; &lt;code&gt;sudo ufw status numbered&lt;/code&gt; shows the list of rules and &lt;code&gt;Status: active&lt;/code&gt;. It is also worth looking at what is listening on the network at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -tulpn &lt;span class="o"&gt;|&lt;/span&gt; grep LISTEN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The address &lt;code&gt;127.0.0.1&lt;/code&gt; in the output means the service is available only to the server itself, and that is fine. What should give you pause is &lt;code&gt;0.0.0.0&lt;/code&gt; next to something you never opened outward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5. Install fail2ban
&lt;/h2&gt;

&lt;p&gt;Password guessing will not stop because passwords are off — it will simply stop being dangerous. But the log entries remain, and with them the load. Fail2ban bans an address after a few failed attempts:&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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the file &lt;code&gt;/etc/fail2ban/jail.local&lt;/code&gt;:&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="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;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;p&gt;&lt;strong&gt;The check:&lt;/strong&gt;&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 fail2ban
sudo fail2ban-client status sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should hold the lines &lt;code&gt;Currently failed&lt;/code&gt; and &lt;code&gt;Total banned&lt;/code&gt;. An error about an unavailable jail instead means it did not come up.&lt;/p&gt;

&lt;p&gt;A common case on Debian 12 and newer: the jail is running, but the counters stay at zero although failed logins are visible in the journal. The reason is that the system file &lt;code&gt;/var/log/auth.log&lt;/code&gt; may not exist at all — the entries go to the systemd journal. One line in the same section fixes it:&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;backend&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;systemd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6. Turn on automatic updates
&lt;/h2&gt;

&lt;p&gt;The update from step one will be out of date in a week. So that you do not have to come back to it by hand:&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
sudo dpkg-reconfigure -plow unattended-upgrades
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The check:&lt;/strong&gt; a trial run shows exactly what would be installed, changing nothing:&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 -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A day later the result appears in &lt;code&gt;/var/log/unattended-upgrades/unattended-upgrades.log&lt;/code&gt;. By default only security updates are installed, and that is a sensible setting: it closes holes without touching the versions of the programs your site depends on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you end up with
&lt;/h2&gt;

&lt;p&gt;An hour of work, and the server is no longer an easy target: passwords are not guessable, spare ports are closed, persistent addresses are cut off, patches install themselves. That is enough to start deploying on it whatever it was bought for.&lt;/p&gt;

&lt;p&gt;What remains is the question those six steps do not answer: how do you know all of it still works. Keys can be quietly reverted to passwords by the next edit of the configuration, a jail can fall over after an update, automatic updates can stop silently because of a held apt lock. Nobody is going to run six commands by hand every week, and a month later the state of the server is unknown again.&lt;/p&gt;

&lt;p&gt;That is what a panel is for: it shows the same checks on one screen and marks the moment one of them stops passing. Arcivéo has a &lt;a href="https://arciveo.com/en/free" rel="noopener noreferrer"&gt;free edition&lt;/a&gt; that installs with one command, switches on UFW and fail2ban, and from then on shows the state. What the same data looks like on the full panel is on the &lt;a href="https://demo.arciveo.com" rel="noopener noreferrer"&gt;open demo&lt;/a&gt;, no sign-up needed.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://arciveo.com/en/blog/new-vps-first-hour" rel="noopener noreferrer"&gt;arciveo.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

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