Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

For a 1 GB VPS running Ubuntu 24.04 LTS, start by securing SSH access, then apply a default-deny firewall and enable automatic security updates. Add swap only if you have enough disk space and accept that it is slower than RAM. The commands below assume you can connect as a sudo-capable account or use your provider’s console; package names, file paths and service behavior can differ on Debian and other distributions.

Before you begin

This walkthrough is scoped to Ubuntu 24.04 LTS. It does not assume that every Ubuntu image, cloud provider, or other Linux distribution has identical defaults. Check your release and current privileges first:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cat /etc/os-release
whoami

Keep an existing SSH session open while making access changes, and make sure you can use your provider’s web console or recovery console if one is available. A firewall mistake or an SSH configuration error can lock you out of a remote machine. Do not close the working session until you have tested a fresh connection using the new account and key.

Create a non-root administrator and confirm key access

Use a regular account with sudo for administration rather than logging in as root. If you already have a non-root sudo account and can log in to it with an SSH key, you can move to the SSH hardening section.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
  1. Connect using the access method supplied by your VPS provider. Create a user, replacing adminuser with the account name you want:

    sudo adduser adminuser
    sudo usermod -aG sudo adminuser
    

    adduser prompts you to set a password and may ask for optional user details. The account password is not a substitute for an SSH key; it is used for local account administration and may be needed by sudo depending on the image’s configuration.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Install the public half of your SSH key for that user. Make the SSH directory and set its permissions:

    sudo install -d -m 700 -o adminuser -g adminuser /home/adminuser/.ssh
    

    Append the complete public-key line, commonly found in a local file ending in .pub, to /home/adminuser/.ssh/authorized_keys. For example, from your local computer you can use ssh-copy-id adminuser@SERVER_IP if that utility is installed and your current login method permits it. Otherwise, transfer the public key through your provider’s console or another trusted route. Do not copy your private key to the VPS.

  3. Set ownership and restrictive permissions on the authorized-keys file:

    sudo chown adminuser:adminuser /home/adminuser/.ssh/authorized_keys
    sudo chmod 600 /home/adminuser/.ssh/authorized_keys
    

    If you created the file under a different home directory, adjust the path rather than assuming every account uses /home.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Open a second terminal on your own computer and test the new account before changing SSH policy:

    ssh adminuser@SERVER_IP
    

    Confirm that the session authenticates with the intended key, then verify sudo works:

    sudo -v
    

    Resolve any key, ownership, permission, or sudo issue while the original session remains available. Only continue when the new session works.

Harden SSH without losing access

Ubuntu’s OpenSSH configuration loads drop-in files from /etc/ssh/sshd_config.d/. For most directives, the first value encountered is used. A file named 99-hardening.conf is a convenient place for local settings, but an earlier drop-in may set a value first. Check the effective configuration after making changes rather than assuming the filename guarantees precedence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create or edit the hardening drop-in:

    sudo nano /etc/ssh/sshd_config.d/99-hardening.conf

    Add these settings:

    PermitRootLogin no
    PasswordAuthentication no
    KbdInteractiveAuthentication no
    MaxAuthTries 3
    

    Disabling password and keyboard-interactive authentication means users need another configured authentication method, normally a valid SSH key. Do not apply these settings until the key login test above succeeds. If your environment relies on an alternate authentication mechanism, verify that it remains available before disabling it.

    Rank #2
    EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
    • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
    • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
    • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
    • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
    • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
  2. Validate the configuration syntax before reloading or restarting the service:

    sudo sshd -t

    No output indicates that the syntax check passed. If it reports an error, fix the file and rerun the check; do not restart SSH with a configuration that fails validation.

  3. Inspect effective values for the two core access controls:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    sudo sshd -T | grep -E 'permitrootlogin|passwordauthentication'
    

    The expected output includes permitrootlogin no and passwordauthentication no. If it shows a different value, inspect the included configuration files for an earlier setting and correct the precedence issue.

  4. Restart the SSH service only after the syntax test succeeds, and keep the original session open while testing another fresh connection:

    sudo systemctl restart ssh

    On Ubuntu 24.04, SSH can use socket activation. If you intend to change SSH’s port, do not treat editing sshd_config alone as sufficient: the socket configuration may also need to be updated. Apply the matching firewall rule before restarting or changing the listener, and verify the new port from a second session before ending the old one. This guide leaves SSH on its existing port.

Set a default-deny firewall with UFW

UFW can block unsolicited incoming connections while allowing outbound traffic. Before enabling it, identify the port on which you currently reach SSH. The commands below use the standard OpenSSH application profile; if your VPS uses a custom SSH port or the profile is unavailable, allow the actual TCP port instead. A firewall enabled without an SSH allow rule can cut off remote access.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Set incoming traffic to deny by default and outgoing traffic to allow:

    sudo ufw default deny incoming
    sudo ufw default allow outgoing
    
  2. Allow SSH. Choose one of the following approaches, not both:

    sudo ufw allow OpenSSH
    

    Or, to rate-limit new SSH connections using UFW:

    sudo ufw limit OpenSSH
    

    If the profile does not match your SSH listener, substitute the actual port, for example sudo ufw limit 2222/tcp for a listener on TCP port 2222. Do not leave both a broad allow rule and a rate-limit rule for the same SSH service if your intent is to use the limit rule; the allow rule may defeat the point of the rate limit.

  3. Only if this VPS will serve web traffic, allow HTTP and HTTPS:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Rank #3
    BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
    • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
    • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
    • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
    • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
    • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
    sudo ufw allow 80/tcp
    sudo ufw allow 443/tcp
    

    Do not open ports merely because a software package might use them later. Add a rule when a service is actually intended to accept external connections.

  4. Enable UFW and inspect the resulting policy:

    sudo ufw enable
    sudo ufw status verbose
    

    Review the output before closing your working session. It should show the intended SSH access and only the additional ports you deliberately opened. If a required port is missing, add the rule from the active session and check the status again.

UFW limiting and fail2ban are different controls

UFW’s limit rule is connection-rate based. fail2ban is an optional, log-based tool that can ban addresses after matching failed-login activity. They address related but different signals and can be used together; neither should replace SSH keys, a correct firewall policy, or a working recovery path.

Control What it reacts to What to know
UFW limit Connection attempts reaching the limited rule Simple to apply at the firewall; the exact threshold is not stated here because the available threshold claim was not confirmed against primary documentation.
fail2ban Matching events in service logs, such as SSH authentication failures Optional additional service. Its jail and firewall action must be configured correctly for the server.

If you choose to install and configure fail2ban, one common configuration pattern uses a UFW ban action and a stricter SSH daemon jail. After configuring it, check the SSH jail with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo fail2ban-client status sshd

The status command is useful only if fail2ban is installed and the sshd jail is enabled. Do not add the package merely to satisfy a checklist; the core setup can use UFW without it.

Enable automatic security updates

Ubuntu’s unattended-upgrades package is installed by default on Ubuntu images in the scope of this guide, and its default configuration applies security updates. Verify its state rather than assuming the image has retained that configuration. The package’s settings are held in /etc/apt/apt.conf.d/, including 50unattended-upgrades and 20auto-upgrades. Ubuntu security guidance recommends putting custom changes in a separate drop-in rather than editing 50unattended-upgrades directly.

  1. Install the update tools if they are missing:

    sudo apt update
    sudo apt install unattended-upgrades apt-listchanges
    
  2. Run the configuration dialog to enable unattended upgrades:

    sudo dpkg-reconfigure -plow unattended-upgrades

    Choose to enable automatic installation when prompted. The default behavior is security-focused; do not assume this automatically installs every available update from every software source.

    What’s actually slowing this PC down?

    Pick the symptom - the matching free tool is one click away.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Review the configuration files if you need to customize update origins or scheduling. Preserve the package-provided file and place local overrides in an appropriate separate file under /etc/apt/apt.conf.d/. Configuration changes can alter what is installed, so inspect the resulting behavior rather than adding unverified directives.

  4. Check the service state and review the update log:

    systemctl is-enabled unattended-upgrades
    sudo less /var/log/unattended-upgrades/unattended-upgrades.log
    

    The expected enabled-state result is enabled. The log helps confirm what the updater has processed; it does not replace checking whether a particular service needs a restart.

  5. Run a dry-run diagnostic when you want to see what unattended-upgrades would do without applying updates:

    Rank #4
    Sale
    Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
    • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
    • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
    • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
    • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
    • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
    sudo unattended-upgrades --dry-run --debug

Decide deliberately how reboots should be handled. Automatic security updates and automatic reboots are separate operational concerns: a reboot can interrupt services or a workload in progress. If you enable automatic reboot behavior, account for the service impact and schedule it appropriately rather than assuming an unattended reboot is harmless.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Decide whether to add swap

Many cloud images do not include swap. On a machine with 1 GB of RAM, a swap file can provide additional space for memory pages when RAM is under pressure, but it is disk-backed and should not be treated as a replacement for physical memory. The frequently suggested size of 1–2 GB for a 1 GB VPS, including a 2 GB example, and a vm.swappiness value of 10 come from common guides rather than confirmed primary-source sizing guidance. Treat them as starting conventions, not Ubuntu requirements or performance guarantees.

Check existing swap and available disk space

Before creating a file, see whether swap is already active and whether the VPS has room for another file:

free -h
swapon --show
df -h /

If swapon --show already lists active swap, do not blindly create another file. If disk space is tight, do not allocate a large swap file at the expense of the operating system or application data.

Create a 2 GB swap file if that fits your disk and needs

The following is a common setup example, not an official sizing recommendation. Use a different size only after considering available disk space and your workload.

  1. Create the file, restrict access, and format it:

    sudo fallocate -l 2G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    

    If fallocate fails, stop and investigate the filesystem and available space rather than proceeding as if a valid file was created.

  2. Enable the swap file for the current boot:

    sudo swapon /swapfile
    
  3. Make the file available after reboot by adding this line to /etc/fstab:

    /swapfile none swap sw 0 0

    Append the line once only. If it is already present, do not duplicate it.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Optionally set the commonly used swappiness value in a sysctl drop-in. This value is a tuning convention rather than verified official guidance for every 1 GB VPS:

    echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
    sudo sysctl --system
    
  5. Verify the active result:

    free -h
    swapon --show
    

    The swap file should appear in swapon --show. If it does not, review the commands and system output before assuming the file is active.

Swap may reduce the chance that a short-lived memory spike immediately exhausts available memory, but it cannot make a memory-heavy workload behave like one running on a larger-RAM server. If the machine is persistently relying on swap, consider reducing the workload or moving to a VPS with more memory.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Verify the finished configuration

Run these checks from your administrator account after making the changes:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Confirm the effective SSH settings:

    sudo sshd -T | grep -E 'permitrootlogin|passwordauthentication'

    Look for permitrootlogin no and passwordauthentication no.

  • Review the firewall’s active rules:

    sudo ufw status verbose

    Confirm that SSH uses the expected port or profile and that only intentional service ports are listed.

  • Check unattended-upgrades enablement:

    systemctl is-enabled unattended-upgrades

    It should return enabled for the setup described here.

  • Check memory and swap, if you configured swap:

    free -h
    swapon --show
  • Open a new SSH session and authenticate as the non-root administrator using the intended key. Keep the existing session until that test succeeds.

    Free tools Windows power users keep installed

    One-click scans. No signup required.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common problems and recovery

The new account cannot log in with its key

Do not disable password authentication or close the original working session. Confirm that the public key was copied as a complete line to the account’s authorized_keys file, then check its ownership and permissions. The key must correspond to the private key offered by the client. Correct the account path if the user’s home directory is not /home/adminuser.

SSH reports a configuration error

Run sudo sshd -t and fix the reported syntax problem before restarting the service. If syntax passes but sshd -T shows an unexpected effective value, check earlier files in /etc/ssh/sshd_config.d/; an earlier value may take precedence over the new drop-in.

You cannot connect after enabling UFW

If the old session is still active, use it to inspect sudo ufw status verbose and add an allow or limit rule for the actual SSH port. If remote access is already lost, use the VPS provider’s console or recovery mechanism to correct the firewall. Do not assume that an OpenSSH profile automatically covers a custom port.

A port change does not take effect

Ubuntu 24.04 may use socket activation for SSH. A port change can therefore require updating the socket configuration as well as the SSH daemon configuration. Also ensure the firewall permits the new port before restarting or reloading the listener. Because these settings vary by image, keep an existing session and test the new port separately before closing it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Swap is absent or the disk is nearly full

Use swapon --show to check whether swap is actually active, and df -h / to inspect space on the root filesystem. Do not keep retrying a failed allocation without checking its error and the available storage. If swap is active but the machine continuously depends on it, reduce memory demand or choose a larger-memory server rather than treating swap as extra RAM.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.