Ubuntu SSH Server Install: How to Install and Run openssh-server
Part of New VPS setup, our guide to this topic
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.
On this page
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.

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.
Install the SSH server on Ubuntu: 4 steps
Replace yourname and YOUR_SERVER_IP with your own values.
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.
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.
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/ 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
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.
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.
- 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.
- 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.
Drop-ins in sshd_config.d/ override the main file. Source: documentation.ubuntu.com, captured Nov 20, 2026.
- 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.
- Keep your current session open, then connect on the new port from a second terminal:
your computerssh -p 2222 yourname@YOUR_SERVER_IP
- 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
- To install an SSH server on Ubuntu, run
sudo apt install openssh-server; the daemon issshd, the service isssh. - On 24.04,
ssh.socketholds port 22 and starts the service on the first connection — an inactivesshwith a listening socket is normal. - Allow SSH in ufw with
sudo ufw allow OpenSSHbefore you rely on it. - Changing the port is a drop-in
Portline, thensudo sshd -t,sudo systemctl daemon-reloadandsudo systemctl restart ssh.socket— with a session left open. - 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 · provider | vCPU · RAM · disk | You pay | Visit |
|---|---|---|---|
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.