jamielab@console :: /_posts/2025-12-24-setting-up-ssh.md
online 2026-02-03 05:32
Setting up SSH on a Linux Server

Setting up SSH on a Linux Server

A quick guide on getting SSH up and running securely.

When getting a new Linux server or VM ready for remote access, setting up SSH (Secure Shell) is one of the first tasks. Here’s a quick guide to get you started securely.

The first steps

  1. Install OpenSSH Server (if not already installed):
# 1. Install OpenSSH Server
sudo apt update
sudo apt install openssh-server

2. Configure SSH

Edit the SSH configuration file to enhance security:

# 2. Edit SSH configuration
sudo nano /etc/ssh/sshd_config

Make the following changes:

  • Change the default port (optional but recommended): Port 2222
  • Disable root login: PermitRootLogin no
  • Allow only specific users (optional): AllowUsers your_username
  • Save and exit the file.
  • Restart the SSH service to apply changes:
    sudo systemctl restart sshd
    

    Enable UFW Firewall

    To secure your SSH server, it’s a good idea to set up a firewall using UFW (Uncomplicated Firewall).

# 1. Default deny incoming, allow outgoing
sudo ufw default deny incoming
sudo ufw default allow outgoing 
# 2. Allow SSH on the new port
sudo ufw allow 2222/tcp
# 3. Enable it
sudo ufw enable

Check status

sudo ufw status numbered

Quick, easy, and essential for a secure lab environment.

Comments