Skip to main content
How To

How to Enable SSH on Ubuntu

With SSH enabled in server mode, you can connect to your present system from other remote systems. In client mode, you can connect to remote systems from your current system.

Pratham Patel

The SSH (Secure SHell) protocol is what almost every UNIX and UNIX-like operating systems use for remotely logging into a machine as if it were a local shell.

OpenSSH is a collection of software that implement the SSH protocol, developed by the OpenBSD Project.

OpenSSH packages

If you manually installed Ubuntu Server, you were asked to install OpenSSH server. But that is not the case with most installations. So let us go over how you can install OpenSSH packages manually.

There are two main packages one needs to look for, to enable SSH on Ubuntu. They are as follows:

  • openssh-server: The server part of OpenSSH allows you to connect from other systems, using proper authentication, to your system (usually suitable for the servers).
  • openssh-client: The client part allows you to SSH into a remote server from your current system (usually suitable for the desktops).

Based on your needs, you may install either package, or both packages.

Installing openssh-server

On my Ubuntu server, which I need to access remotely, I will run the following command:

sudo apt-get install openssh-server

This will install OpenSSH Server on my computer.

Once the installation is complete, I will enable the ssh systemd service using the command given down below:

sudo systemctl enable --now ssh.service
It is okay to use sshd.service, but the openssh-server package on Ubuntu provides ssh.service, so better use that. Meanwhile, on Fedora, it is sshd.service. :-)

This command will not only enable the ssh systemd service, but it will also start it immediately.

Open network port (if necessary)

Ubuntu uses the ufw tool as the default firewall configurator. Make sure that the ports SSH needs are open. Run the following command to allow SSH port through the firewall:

sudo ufw allow ssh

Done! Following these steps will enable you to access your Ubuntu computer remotely, over the network.

Cloud Computing & Linux Servers | Alternative to AWS | Linode
Simplify your infrastructure with Linode’s cloud computing and hosting solutions and develop, deploy, and scale faster and easier.

Installing openssh-client (on desktop)

There isn't much to do on the client side. Usually, Ubuntu installs the openssh-client package by default.

If, for some reason, it wasn't installed, run the following command:

sudo apt-get install openssh-client

This package provides several packages:

  • scp: secure copy (cp over network)
  • sftp: secure FTP
  • ssh: the ssh client, used to log into remote computers
  • ssh-keygen: create SSH keys

Now that we have ssh command available, the syntax to log into a remote computer is as follows:


As evident, you need to provide the username of the user that you wish to log in as. You can also replace the IP address with the hostname of the remote computer.

For example, my remote computer has the user pratham and the hostname is will use the following command to log into my remote machine:

ssh [email protected]

In case I wish to log in using an IP address, I will do the following:

ssh [email protected]

With this, I will be asked for a password. This password is the login password of user pratham.

Use a different port

Some servers, to prevent attacks will change the port used for SSH. The default port is 22.

No worries, this can be easily taken care of (if you know which port to use) using the -p option.

Specify the port number after like so:


Say I changed the SSH port on my remote computer from 22 to 108, I will log in like so:

ssh -p 108 [email protected]

Troubleshooting tip

In case you have problems logging into your remote computer, make sure that the username and IP address are correct. Typos happen :)

If you have the correct credentials and want to see what is causing a connection error, use the -v option.

There are 3 levels of verbosity, each level can be indicated by the number of occurrences of -v.

If I want maximum verbosity (level 3), use the option -v in the following manner:

ssh -vvv [email protected]

That is all there is to enable SSH on Ubuntu :)

Need help or suggestions? Feel free to leave a comment below.

Pratham Patel