If you didn’t enable the default OpenSSH server during the initial Ubuntu in­stal­la­tion, you can add it at any time. Once OpenSSH is installed via the terminal, you can also adjust the Ubuntu SSH daemon’s con­fig­u­ra­tion to suit your needs.

Free VPS Trial
30-day money-back guarantee

Try out your VPS for 30 days. If you're not satisfied, you get your money back.

How to install Ubuntu SSH server step by step

To enable secure remote access to a computer or server, SSH (Secure Shell) is essential. This security protocol in­cor­po­rates three core elements that protect remote con­nec­tions:

  • Au­then­ti­ca­tion of the remote endpoint ensures that you never contact the wrong party (whether client or server).
  • En­cryp­tion of data trans­mis­sion prevents unau­tho­rized parties from reading the in­for­ma­tion.
  • Ensuring data integrity makes trans­mit­ted data tamper-proof.

Linux dis­tri­b­u­tions such as Ubuntu have long relied on the open-source OpenSSH suite to use SSH and to enable secure file transfers via SCP or SFTP.

By default, OpenSSH is not enabled in a fresh Ubuntu in­stal­la­tion, which means you first need to enable Ubuntu SSH. Below, you’ll learn how to do this step by step and which con­fig­u­ra­tion options are available once the Ubuntu SSH server is running.

Note

If you set up an Ubuntu server and use the Ubuntu Server Edition for this purpose, you’ll have the option to enable Ubuntu SSH during in­stal­la­tion.

Step 1: Open the terminal

To install Ubuntu SSH via install or enable it, you’ll need the terminal—the Linux dis­tri­b­u­tion’s command-line tool. Your first step is therefore to open this handy ad­min­is­tra­tion tool. The easiest way to do this is by using the keyboard shortcut [Ctrl] + [Alt] + [t].

Al­ter­na­tive­ly, you can start the terminal via the “Show Ap­pli­ca­tions” menu by clicking the button of the same name and using the search function to look for “terminal”.

Image: Ubuntu search function: Search for “terminal”
Ubuntu search function: Search for “terminal”
Tip

Do you want to set up secure SSH con­nec­tions to a server or service? Create your SSH keys in Ubuntu yourself in just a few steps.

Step 2: Install the Ubuntu SSH service

With the Ubuntu install command for the SSH service, you can now install Ubuntu SSH (OpenSSH) in the command-line tool you opened. The command is as follows:

sudo apt install openssh-server
bash
Image: OpenSSH installation in the Ubuntu terminal
OpenSSH in­stal­la­tion in the Ubuntu terminal

Enter your user password and confirm it by pressing Enter to start in­stalling the Ubuntu SSH service.

Tip

In­stalling OpenSSH differs only slightly across the various Ubuntu versions. You can use the method described to install Ubuntu SSH both on SSH on Ubuntu 24.04 and on older editions.

Step 3: Check the status and enable the Ubuntu SSH server if needed

After in­stalling Ubuntu SSH, you can use the following command to check whether the SSH daemon is running as expected:

sudo systemctl status ssh
bash

In the command output, the Ubuntu SSH service is running if you see the status “active (running)”. To ensure SSH is also available after every system reboot, the “Loaded” line should ad­di­tion­al­ly show “vendor preset: enabled”.

Image: Terminal output for the OpenSSH status check
Terminal output for the OpenSSH status check

If the SSH service is still inactive and automatic startup on reboot isn’t enabled either, you can change this by entering two ad­di­tion­al commands:

sudo systemctl enable ssh
sudo systemctl start ssh
bash

Press “q” to exit the SSH status output and return to the command line prompt.

Step 4: Open the SSH port

To be able to connect to your Ubuntu system from anywhere via Ubuntu SSH, the network protocol port (default: TCP port 22) must also be open. Only then can you suc­cess­ful­ly establish a remote con­nec­tion with SSH clients like PuTTY.

Ubuntu includes UFW, its own con­fig­u­ra­tion tool for the built-in firewall. Set up a cor­re­spond­ing rule in this tool for SSH com­mu­ni­ca­tion so that the port is open for incoming and outgoing data:

sudo ufw allow ssh
bash
Image: Opening the SSH port via the Ubuntu terminal
Opening the SSH port via the Ubuntu terminal
Tip

A closed port is often the reason SSH con­nec­tions fail. There are also several other possible issues that can prevent secure SSH con­nec­tions from being es­tab­lished. In general, you can fix SSH errors easily if you’re familiar with the most common causes.

Step 5: Configure the Ubuntu SSH server

The default OpenSSH con­fig­u­ra­tion is already well suited for secure remote con­nec­tions to your Ubuntu system. However, you can adjust the standard settings if you want to change the com­mu­ni­ca­tion port, define a specific Internet Protocol version, or disable TCP for­ward­ing.

All SSH-related settings for Ubuntu are managed in the central con­fig­u­ra­tion file sshd_config. To apply changes, open this file using a text editor of your choice (for example, nano) as shown below:

sudo nano /etc/ssh/sshd_config
bash
Image: Contents of the OpenSSH configuration file sshd_config
Contents of the OpenSSH con­fig­u­ra­tion file sshd_config

Adjust the contents of the con­fig­u­ra­tion file to your needs and save your changes before closing it. Then restart OpenSSH so the changes take effect:

sudo service ssh restart
bash
Tip

Setting up Ubuntu SSH is worth­while, es­pe­cial­ly if you plan to use an Ubuntu FTP server. This allows you to offer the secure FTP al­ter­na­tive SFTP mentioned earlier.

Reviewer

Go to Main Menu