Install the OpenSSH server (openssh-server) to log in to a machine remotely over SSH. The installation command on Ubuntu 26.04 is the same as on 24.04. But OpenSSH is now version 10.2p1, and systemd socket activation is the default.
This post installs the OpenSSH server on Ubuntu 26.04 and then sets up key-based authentication, hardening, and the firewall.
Install openssh-server
sudo apt update
sudo apt install -y openssh-server
The package maintainer script generates the host keys and adds ssh.socket to sockets.target. The 26.04 package also includes sshd-keygen.service, which generates the host keys.
Check socket activation
systemctl status ssh.socket ssh.service --no-pager
Right after the installation, ssh.service is disabled and inactive (dead). systemd (PID 1) listens on port 22 through ssh.socket.
sudo ss -tlnp | grep -E 'State|:22 '
ssh -V
| Unit | Role | State after installation |
|---|---|---|
ssh.socket | Listens on the port and waits for the first connection | enabled, active (listening) |
ssh.service | The sshd process. Starts at the first connection | disabled, inactive (dead) |
First connection and host key verification
Log in from the client with a password for the first time. In the commands below, $ID is the account on the server and $PW is its password. When SSH asks about the host key, enter yes, then enter $PW.
ssh $ID@$TARGET_IP
systemctl is-active ssh.service
Before you enter yes, check the fingerprint on the server. The fingerprint from ssh-keygen -lf must match the one on the client.
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
systemctl status ssh.service --no-pager
After the first connection, ssh.service is started with TriggeredBy: ssh.socket and keeps running.
Set up key-based authentication
Generate an Ed25519 key pair on the client. Do not leave the passphrase empty.
ssh-keygen -t ed25519 -C "$ID@client"
Add the public key to ~/.ssh/authorized_keys on the server with ssh-copy-id. You enter $PW once in this step.
ssh-copy-id $ID@$TARGET_IP
Log in again with the key, and check the authentication method and the key exchange (kex) algorithm.
ssh -v $ID@$TARGET_IP true 2>&1 | grep -E 'kex: algorithm|Server accepts|Authenticated'
The key exchange algorithm depends on the client version. With the OpenSSH 10.2p1 client of 26.04, SSH selects an ML-KEM based algorithm.
| Client | Negotiated key exchange algorithm |
|---|---|
| Ubuntu 24.04 (OpenSSH 9.6p1) | sntrup761x25519-sha512@openssh.com |
| Ubuntu 26.04 (OpenSSH 10.2p1) | mlkem768x25519-sha256 |
Both are hybrid post-quantum algorithms. You do not need to change the server configuration.
Harden sshd with sshd_config.d
Line 24 of /etc/ssh/sshd_config has Include /etc/ssh/sshd_config.d/*.conf. The directory is empty after the installation. Keep the main file unchanged and put your settings in a new drop-in file.
sudo tee /etc/ssh/sshd_config.d/10-hardening.conf <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
MaxAuthTries 3
AllowUsers $ID
EOF
sudo sshd -t && echo syntax-ok
sudo sshd -T | grep -E '^(passwordauth|kbdinteractiveauth|permitrootlogin|maxauthtries|allowusers)'
sudo systemctl restart ssh
sshd -t checks only the syntax. To see the effective values, use sshd -T.
| Option | Value | Effect |
|---|---|---|
PasswordAuthentication | no | Disables password authentication |
KbdInteractiveAuthentication | no | Disables the PAM keyboard-interactive path that asks for a password |
PermitRootLogin | no | Disables root login |
MaxAuthTries | 3 | Limits authentication attempts per connection to 3 |
AllowUsers | $ID | Allows only the listed users to log in |
From the client, a password login and a root login both fail. A key login still works.
ssh -o PubkeyAuthentication=no $ID@192.168.0.57
ssh root@192.168.0.57
ssh $ID@192.168.0.57 hostname
If several files set the same option, the first value that sshd reads wins. A file named 05-legacy.conf sorts first, so it changes the result.
$ echo 'PasswordAuthentication yes' | sudo tee /etc/ssh/sshd_config.d/05-legacy.conf
$ ls /etc/ssh/sshd_config.d/
05-legacy.conf
10-hardening.conf
$ sudo sshd -T | grep ^passwordauthentication
passwordauthentication yes
$ sudo rm /etc/ssh/sshd_config.d/05-legacy.conf
$ sudo sshd -T | grep ^passwordauthentication
passwordauthentication no
Check the login log
sudo journalctl -u ssh.service -n 6 --no-pager
sshd rejects the root login with not listed in AllowUsers. Since OpenSSH 9.8, each connection runs in a separate sshd-session process, so the log shows this name.
Configure the ufw firewall
ufw is installed but disabled by default. Allow SSH first, then enable ufw.
sudo ufw app info OpenSSH
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose
The OpenSSH application profile opens 22/tcp.
Cautions
- In a remote session, run
ufw allowbeforeufw enable. In the other order, you lose the current SSH connection. - Test the key login in a new terminal before you disable password authentication. Keep the existing session open. If the key login fails, use that session to revert the configuration.
- Check the files in
sshd_config.dbefore you change settings. The directory is empty after installation, but other packages or management tools can add files. The first value read wins, so check the effective values withsshd -T. - Do not accept the host key prompt without checking. Compare it with the fingerprint from
ssh-keygen -lfon the server, then enteryes.
Conclusion
The command to install the SSH server on 26.04 is the same as on 24.04. The differences are socket activation and the OpenSSH 10 defaults. Put your settings in a sshd_config.d drop-in file and check the effective values with sshd -T.
This is a referral link. I may receive credit if you sign up, at no extra cost to you.
Try it on a cloud server — Deploy Ubuntu on VultrReferences
- Ubuntu Discourse — sshd now uses socket-based activation
- OpenSSH Release Notes
- sshd_config(5) — OpenSSH manual page