VPSGauge

Ubuntu SSH Server Install: How to Install and Run openssh-server

Updated Nov 14, 2026 · by Kane · how we check

Part of New VPS setup, our guide to this topic

Short answer

Ubuntu SSH server install is one command: sudo apt install openssh-server. On Ubuntu 24.04 the service is called ssh and starts through socket activation, so ssh.socket holds port 22 and there is nothing to start by hand. Check it with systemctl status ssh, allow SSH in your firewall, and change the port from 22 only with one session left open.

Time
15 min
Steps
4
Works on
Ubuntu
24.04 LTS
On this page
  1. Before you start
  2. Install the SSH server on Ubuntu: 4 steps
    1. 1Install openssh-server
    2. 2Check that it’s running
    3. 3Allow SSH in the firewall
    4. 4Change the SSH port (optional)
  3. Key takeaways
  4. A VPS for this guide
  5. Common Ubuntu SSH server problems
  6. Questions

This guide has no affiliate links in the steps.

This is the server side of SSH: sshd, the program that answers incoming connections. Most VPS images ship it already, but a minimal Ubuntu install or a container image may not, and you’ll need it again if you removed it. If you’re still trying to connect for the first time, start with how to SSH into a VPS; key login is covered separately in SSH key login. If the box is brand new, the new VPS setup checklist is the thing to finish after this.

A terminal on your computer connected to a server rack through a padlocked line: the SSH server is the part on the server that answers.

Before you start

You need two things:

  • A server running Ubuntu 24.04 LTS, and a way to reach it: an existing SSH session, or your provider’s web console (VNC or serial). If you only have the console, everything below works from it.
  • A sudo user. Run the install as your own user, not root.

Two facts shape everything that follows, and both are specific to 24.04. First, the service is named ssh, not sshd (sshd is only an alias), and it is socket-activated: ssh.socket holds port 22 and starts the ssh service when the first connection arrives; after that the service keeps running. Socket activation arrived in Ubuntu 22.10, which is why older tutorials that say “just restart ssh” are only half right on 24.04. Second, the config lives in /etc/ssh/sshd_config, and drop-in files in /etc/ssh/sshd_config.d/ override it — that folder is where your own changes belong.

SOCKET ACTIVATION ON UBUNTU 24.04 YOUR COMPUTER ssh yourname@IP connects to :22 SSH.SOCKET holds port 22 active (listening) always on SSH.SERVICE (SSHD) starts at 1st login then keeps running checks key or password Before anyone connects, systemctl status ssh can say inactive (dead): normal. The port lives in ssh.socket: daemon-reload, then restart ssh.socket.
SOCKET ACTIVATION, 24.04 YOUR COMPUTER ssh yourname@IP → port 22 SSH.SOCKET holds port 22, always on active (listening) 1st connection SSH.SERVICE (SSHD) starts at 1st login then keeps running checks key or password Before anyone connects, status ssh can say inactive (dead): that's normal. Port change: daemon-reload, then restart ssh.socket.

Install the SSH server on Ubuntu: 4 steps

How to Install an SSH Server on Ubuntu 24.04 (Abstract programmer) · YouTube (loads when you press play)

Replace yourname and YOUR_SERVER_IP with your own values.

1

Install openssh-server

On the server:

serversudo apt update
sudo apt install openssh-server

openssh-server is the daemon, sshd. The client you type into on your own computer is the separate openssh-client package — that’s not what you’re installing here. Ubuntu 24.04 ships OpenSSH 9.6p1, recent enough that you don’t need an extra repository.

Ubuntu Server documentation, Install OpenSSH: to install the OpenSSH server application and related support files, run sudo apt install openssh-server. The install line, straight from Ubuntu’s own server docs. Source: documentation.ubuntu.com, captured Nov 20, 2026.

If it fails: Unable to locate package openssh-server. The package index is stale; run sudo apt update first, then install again.

2

Check that it’s running

serversystemctl status ssh

Check: A status screen for the ssh service. Because 24.04 uses socket activation, the service itself may say inactive (dead) on a box nobody has connected to yet — that’s normal. The unit that actually holds the port is the socket:

serversystemctl status ssh.socket

Check: Active: active (listening) and a 22/tcp listen address in the output. To see it at the OS level instead, ss -lnt lists every listening port.

If it fails: The socket is inactive too. Start and enable it:

serversudo systemctl enable --now ssh.socket
3

Allow SSH in the firewall

If you’ve enabled ufw (step 6 of the new VPS setup checklist), open SSH before you depend on it:

serversudo ufw allow OpenSSH

OpenSSH is the ufw app profile for port 22. If you plan to change the port in step 4, skip this line and allow the new port there instead. The full ufw workflow is in our ufw firewall guide.

4

Change the SSH port (optional)

Moving off port 22 cuts the scanner noise in your logs, but it is not real security — key login and a firewall do more. If you want it, follow this order so you never lock yourself out.

  1. Allow the new port in the firewall while 22 still works:
serversudo ufw allow 2222/tcp

Pick any port from 1024 to 65535; 2222 is the example.

  1. Put the port in a drop-in config:
serversudo nano /etc/ssh/sshd_config.d/00-port.conf
00-port.conf — nanoPort 2222

sshd_config pulls in the drop-ins from its very first line, so they take precedence over the main file, and a name starting 00- is read before any file a cloud image puts in the same folder.

Ubuntu Server documentation: Ubuntu’s sshd_config starts with Include /etc/ssh/sshd_config.d/*.conf, and because OpenSSH uses the first value set for most directives, settings in sshd_config.d/ override the main configuration file. Drop-ins in sshd_config.d/ override the main file. Source: documentation.ubuntu.com, captured Nov 20, 2026.

  1. Test the config, then restart the socket — not just ssh:
serversudo sshd -t
sudo systemctl daemon-reload
sudo systemctl restart ssh.socket

On 24.04 a systemd generator reads the port from sshd_config and its drop-ins and writes it into ssh.socket, so the socket is what you restart — the two commands Ubuntu’s own openssh package notes give. On an older 22.04 image (from before socket activation), sudo systemctl restart ssh is the equivalent.

CHANGE THE PORT SAFELY 1 · ALLOW NEW PORT ufw allow 2222/tcp 22 still works 2 · SET PORT 00-port.conf Port 2222 3 · RESTART SOCKET sshd -t restart ssh.socket 4 · TEST NEW PORT ssh -p 2222 from a 2nd terminal Keep your current session open — close it only after step 4 connects.
CHANGE THE PORT SAFELY 1 · ALLOW NEW PORT ufw allow 2222/tcp (22 still works) 2 · SET PORT 00-port.conf → Port 2222 3 · RESTART SOCKET sshd -t + restart ssh.socket 4 · TEST NEW PORT ssh -p 2222 from a 2nd terminal Keep your current session open — close it only after step 4 connects.
  1. Keep your current session open, then connect on the new port from a second terminal:
your computerssh -p 2222 yourname@YOUR_SERVER_IP
  1. Once that works, remove the old port from the firewall:
serversudo ufw delete allow OpenSSH

Only now close the old session. If the new login fails, fix the config from the still-open session — or the web console you checked earlier.

Key takeaways

  1. To install an SSH server on Ubuntu, run sudo apt install openssh-server; the daemon is sshd, the service is ssh.
  2. On 24.04, ssh.socket holds port 22 and starts the service on the first connection — an inactive ssh with a listening socket is normal.
  3. Allow SSH in ufw with sudo ufw allow OpenSSH before you rely on it.
  4. Changing the port is a drop-in Port line, then sudo sshd -t, sudo systemctl daemon-reload and sudo systemctl restart ssh.socket — with a session left open.
  5. Keys beat ports: see SSH key login, and finish the rest with the new VPS setup checklist. That’s the whole Ubuntu SSH server install.

A VPS for this guide

Everything above runs on any VPS with 1 GB of RAM. The cheapest 1 GB+ plan at each provider whose prices we read every day, IPv4 included:

Plan · providervCPU · RAM · diskYou payVisit
KVM VPS Special 1 GB
RackNerd · Los Angeles +19
1 vCPU·1 GB·20 GB$1.83/mo
VPS pico G11.5s
netcup · Nuremberg
1 vCPU·1 GB·30 GB$2.00/mo
SSD VPS 1
CloudCone · USA
2 vCPU·1 GB·30 GB$2.33/mo
1 slice
InterServer · New York +2
1 vCPU·2 GB·40 GB$3.00/mo
NVMe 2 GB
HostHatch · Amsterdam +15
1 vCPU·2 GB·10 GB$4.00/mo

Prices read Dec 4, 2026. gets that provider's deals on Telegram. Compare every 1 GB plan →

Common Ubuntu SSH server problems

Unable to locate package openssh-server.The package index is stale. Run sudo apt update, then sudo apt install openssh-server again.

systemctl status ssh says inactive.Normal on 24.04 — check ssh.socket instead. If the socket is inactive too, run sudo systemctl enable --now ssh.socket.

Connection refused after you change the port.Either the firewall still blocks the new port, or you forgot sudo systemctl daemon-reload. Allow the new port and retry, or fix it from the web console.

You’re locked out after the port change.Use the still-open session or the provider’s web console. Fix the drop-in, then sudo sshd -t, sudo systemctl daemon-reload and sudo systemctl restart ssh.socket.

Brute-force noise fills the logs.Moving off port 22 helps a little; turning off password login helps a lot — that’s the SSH key login guide.

Questions

Is openssh-server already installed on Ubuntu?

On most VPS images, yes — the provider installs it so you can log in. A minimal Ubuntu ISO or container image may not include it, and sudo apt install openssh-server covers both cases.

What’s the difference between openssh-client and openssh-server?

The client (ssh) is what you type commands into; the server (sshd) is what answers them. Install openssh-server on the machine you’re connecting to — your laptop already has the client.

Do I need to start SSH after installing it?

On Ubuntu 24.04, no. The package enables ssh.socket, which listens on port 22 and starts sshd when a connection arrives. Check it with systemctl status ssh.socket.

Should I change the SSH port from 22?

It’s optional. It reduces scanner noise in your logs but adds little real security — keys and a firewall matter more. If you change it, allow the new port first and keep a session open.

Why does my ssh service show inactive?

Socket activation. On 24.04, ssh.socket is the unit that’s always up; ssh.service starts with the first connection, so it can sit inactive until someone connects.

How big a VPS do I need for an SSH server?

Any size. sshd needs only a few megabytes of memory, so the smallest plan anywhere runs it. The table at the end lists the cheapest 1 GB plan at each provider we read daily.

Can I install SSH on a server I can’t reach?

Yes, if you have the provider’s web console (VNC or serial). Run the install commands there — that console exists precisely for this.

How we checked: The commands follow Ubuntu Server’s OpenSSH server page, the README that ships with Ubuntu’s openssh package for 24.04 (socket activation and port changes), and Ubuntu’s announcement of socket-activated sshd in 22.10, all read November 14, 2026. The OpenSSH version is the one Launchpad lists for 24.04 on the same date. We did not run the steps on every provider’s image, so a provider that ships a customized SSH setup may differ slightly. How we check.

Keep reading