Installing an SSH client lets you connect from your Ubuntu machine. To accept incoming connections, Ubuntu needs the OpenSSH server package. And installing that package is only the first check: you still need to verify that SSH is listening, that the network allows access, and that a login works from another machine.
Check what is already installed
The right starting point depends on how Ubuntu was set up. Ubuntu Desktop often does not include the SSH server by default. Ubuntu Server may have it if you selected SSH during installation, while cloud images often come with SSH configured by the provider.
Check the package before installing it:
dpkg -s openssh-server | grep -E 'Package:|Status:|Version:'
If the output includes Status: install ok installed, the package is present. If it is missing, install it from Ubuntu’s repositories:
sudo apt update
sudo apt install openssh-server
The ssh command is the client; openssh-server provides the daemon that accepts incoming connections. Having the client installed does not mean the machine is accepting SSH connections.
Verify the listener, not just the service status
Ubuntu installations can use systemd socket activation. On newer installations, including typical Ubuntu 24.04 and 26.04 setups, ssh.socket can listen for connections and start ssh.service when a client connects. That means a service status by itself may not tell the whole story.
Check whether TCP port 22 is listening:
sudo ss -ltnp 'sport = :22'
Look for a LISTEN entry. The process shown may be systemd or sshd, depending on how SSH is started. The address matters too: 127.0.0.1:22 accepts connections only through loopback, while a listener on a network interface can accept connections addressed to that interface. A listener alone does not prove a firewall or network will allow remote access.
If you need to understand the startup mode, inspect both units:
sudo systemctl status ssh.socket --no-pager
sudo systemctl status ssh.service --no-pager
For example, ssh.service being inactive does not necessarily mean SSH is unavailable if ssh.socket is listening. If port 22 is not listening, check the units and logs before changing them:
sudo sshd -t
sudo journalctl -u ssh.socket -u ssh.service -b -n 40 --no-pager
On a standard socket-activated installation where the socket has been disabled, sudo systemctl enable --now ssh.socket may restore it. Customized systems and older service-based setups can differ, so check the current configuration rather than enabling units blindly.
Check the firewall before testing remotely
UFW is optional. See whether it is active:
sudo ufw status verbose
If UFW is inactive, its rules are not blocking SSH. You do not need to enable UFW just to install OpenSSH. If UFW is active and SSH uses the default port, inspect and allow the OpenSSH profile:
sudo ufw app info OpenSSH
sudo ufw allow OpenSSH
sudo ufw status numbered
The standard profile normally allows TCP port 22. If SSH is configured to use a different port, allow that port instead. For example, for port 2222:
sudo ufw allow 2222/tcp
A VPS may also have a provider firewall or security group, separate from UFW. And if you are managing a remote machine, do not enable a default-deny firewall or reset its rules without first confirming that SSH is allowed and that you have a recovery route. Otherwise, you can lock yourself out.
Connect from another computer
On the Ubuntu machine, find an address reachable from the client and the account name to use:
hostname -I
whoami
From a different computer, connect with its OpenSSH client. PowerShell on Windows and terminals on macOS and Linux can use the ssh command:
ssh username@SERVER_IP
Replace username with the Ubuntu account name and SERVER_IP with the server’s reachable address. For a custom port, specify it with -p:
ssh -p 2222 username@SERVER_IP
On the first connection, SSH may ask you to trust the server’s host key. Confirm its fingerprint using a trusted source before accepting it. You can display the server’s ED25519 host-key fingerprint on Ubuntu with:
sudo ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
After connecting, commands such as whoami and hostname help confirm which account and machine you reached. A successful login from the client is the end-to-end test; seeing port 22 in ss only confirms a local listener. A connection to 127.0.0.1 from the Windows host to WSL, for instance, does not prove that another computer or the public Internet can reach that instance.
Diagnose the failure you actually see
- Connection refused: Check the target address and port, the listener, and the SSH socket or service.
- Connection timed out: Check UFW, provider firewall rules, routing, and whether you used a reachable address.
- Permission denied (publickey): The server was reached, but authentication failed. Check the account and key configuration; this guide to fixing SSH public-key permission errors covers that specific case.
- Works locally, not from another machine: Check the listener’s address and the network path, including any cloud firewall or router.
For a more detailed client-side view of where a connection fails, run:
ssh -v username@SERVER_IP
If you connect from Windows and are comparing available SSH tools, this overview of SSH clients for Windows may help you choose a client for your workflow.
Keep remote access changes reversible
Installing SSH does not mean it needs to be exposed to every network. Keep Ubuntu security updates current and use an appropriate account and authentication setup. If you change authentication settings or the SSH port, keep an existing session open while you test a new connection. Confirm that the new port is allowed through both the host and provider firewalls before relying on it.
The practical sequence is: check whether openssh-server is installed, install it if needed, verify the actual listener, inspect firewall rules, and test a login from the client that needs access.
I originally published a more detailed version of this guide on the ShadeTerm blog.
I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.
Top comments (0)