In this guide, we will install OpenSSH Server on Ubuntu, determine the server address, configure password and SSH key authentication, and then safely disable password-based login.

ssh

Contents

  1. 1. Installing the SSH server
  2. 2. Finding the IP address and username

1. Installing the SSH server

On Ubuntu, the SSH server is provided by the openssh-server package. Update the package index and install it:

sudo apt update
sudo apt install openssh-server

Start the service and enable it to run automatically at boot:

sudo systemctl enable --now ssh

Check the service status:

sudo systemctl status ssh

The active (running) status means that the SSH server is running. By default, SSH accepts TCP connections on port 22.

Configuring UFW

UFW (Uncomplicated Firewall) is Ubuntu’s standard tool for managing local firewall rules.

Check its current status:

sudo ufw status verbose

If you plan to use UFW, allow SSH connections first:

sudo ufw allow OpenSSH

You can add this rule while UFW is inactive. It will take effect when the firewall is enabled. If you are configuring UFW over a remote SSH connection, allow SSH before enabling the firewall:

sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose

2. Finding the IP address and username

Display the server’s IP addresses:

hostname -I

Example output:

192.168.1.100 172.17.0.1 10.0.2.15

If several addresses are displayed, inspect the available network interfaces:

ip -br addr

Example: