Skip to main content

Ubuntu

Ubuntu Server​

Swap File​

Check Current Swap Status

sudo swapon --show
# Create the 2G swap file:
sudo fallocate -l 2G /swapfile

# Secure the file:
sudo chmod 600 /swapfile

# Format and enable:
sudo mkswap /swapfile
sudo swapon /swapfile

# Make it persistent:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Fine-Tuning (Swappiness)​

The Swappiness parameter defines how often your system uses the swap. It’s a value between 0 and 100.

  • Low (e.g., 10): System avoids swap unless absolutely necessary (good for desktops).
  • High (e.g., 60+): System swaps more aggressively (standard for servers).
cat /proc/sys/vm/swappiness
  • Adjust Swappiness Since your RAM is very limited, you want the system to use RAM as much as possible and only hit the disk (swap) when it’s truly getting tight. Set your swappiness to 10 or 20.
sudo sysctl vm.swappiness=10
  • Cache Pressure

This setting controls how the kernel tends to reclaim memory used for caching of directory and inode objects. On a small server, you want it to be a bit more aggressive in reclaiming that cache.

sudo sysctl vm.vfs_cache_pressure=50

To save these settings permanently, add these two lines to the bottom of

sudo nano /etc/sysctl.conf
vm.swappiness=10
vm.vfs_cache_pressure=50

Reference​

Increase Ubuntu /tmp Size​

  • Open the filesystem table
nano /etc/fstab
  • Add or modify the entry

Scroll to the bottom of the file. Look for an existing line for /tmp.

  • If you see one, modify its size parameter.
  • If you don't see one, add this line at the very bottom (this example sets it to 2 Gigabytes, change 2G to 4G or more if needed):
tmpfs /tmp tmpfs defaults,size=2G,mode=1777 0 0
  • Apply the changes immediately
systemctl daemon-reload
mount -o remount /tmp
  • Verify the change
df -h /tmp
  • Your /tmp size should now properly show 2.0G!
Filesystem Size Used Avail Use% Mounted on
tmpfs 2.0G 32K 2.0G 1% /tmp

Generate the Key Pair with PuTTYgen​

Here's a complete guide to set up SSH key authentication for Ubuntu using PuTTYgen (Windows).

  1. Open PuTTYgen (comes with PuTTY).
  2. Under Parameters:
    • Select RSA (or EdDSA / Ed25519 if available — preferred).
    • Set Number of bits to 4096 (for RSA) or leave default for Ed25519.
  3. Click Generate.
  4. Move your mouse randomly in the blank area until the progress bar fills.
  5. (Optional but recommended) Enter a Key passphrase for extra security.
  6. Click Save private key → save it as something like id_rsa.ppk (or id_ed25519.ppk).
  7. In the box labeled "Public key for pasting into OpenSSH authorized_keys file", copy the entire text (starts with ssh-rsa or ssh-ed25519).

Add the Public Key to Your Ubuntu Server​

Option A – If you can already log in with password:

# On the Ubuntu server
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys

Paste the public key you copied from PuTTYgen (one long line), then save and exit.

chmod 600 ~/.ssh/authorized_keys

Option B – From Windows (using the password once):

You can use plink or just SSH with password and paste it manually as above.

Configure PuTTY to Use the Private Key​

  1. Open PuTTY.
  2. In Session → enter the Ubuntu server’s IP or hostname.
  3. Go to Connection → SSH → Auth → Credentials.
  4. Under Private key file for authentication, click Browse and select your .ppk file.
  5. (Optional) Go back to Session, enter a name under Saved Sessions, and click Save.
  6. Click Open.

You should now log in without a password (only the key passphrase if you set one).

Once key auth is working:

sudo nano /etc/ssh/sshd_config

Set these values:

PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no

Then restart SSH:

sudo systemctl restart ssh

Tips​

  • Prefer Ed25519 keys if your PuTTYgen version supports them (newer and more secure).
  • Keep your .ppk file safe and never share it.
  • If you need the key in OpenSSH format (for use with other tools), in PuTTYgen go to Conversions → Export OpenSSH key.

That’s it — you now have passwordless SSH authentication from Windows to Ubuntu using PuTTYgen.