It doesn’t matter if you didn’t enable the default Ubuntu SSH server OpenSSH during the in­stal­la­tion, this can always be done later. You can customize the Ubuntu SSH daemon con­fig­u­ra­tion once the security feature has been installed through the terminal.

Step by step to in­stalling the Ubuntu SSH server

You will need SSH (Secure Shell) for secure remote access to your own computer or server. There are three important aspects in the security procedure which will ensure remote access:

  • Au­then­ti­cat­ing the remote terminal ensures that the wrong contact person (whether client or server) is not contacted.
  • En­crypt­ing the data trans­mis­sion prevents unau­tho­rized persons from reading any in­for­ma­tion.
  • Ensuring data integrity makes trans­ferred data tamper-proof.

Linux dis­tri­b­u­tions such as Ubuntu have relied on the open source suite OpenSSH for SSH and secure file transfer using SCP or SFTP for years now.

OpenSSH is disabled by default when you reinstall Ubuntu, meaning you must enable the service yourself. We’ll outline in this article how to go about this exactly and which con­fig­u­ra­tion options are available to you after enabling the Ubuntu SSH server.

Note

You’ll get a chance to enable SSH as part of the in­stal­la­tion process if you use the Ubuntu Server Edition to set up an Ubuntu Server.

Step 1: How do I enable the terminal?

The terminal, i.e., the command line tool in the Linux dis­tri­b­u­tion will be required to install or enable the SSH in Ubuntu though the “install” option. Just open the handy ad­min­is­tra­tion tool to begin. The easiest way to do this by using the key com­bi­na­tion [Ctrl] + [Alt] + [t].

Al­ter­na­tive­ly, you can start the terminal from the “Show ap­pli­ca­tions” menu and searching “Terminal” using the search function.

Step 2: How do I install Ubuntu SSH?

You can install OpenSSH in the command line tool using the Ubuntu “install” command for SSH. The command is as follows:

sudo apt install openssh-server

Enter your password and confirm by pressing Enter which will start the in­stal­la­tion of Ubuntu SSH im­me­di­ate­ly.

Step 3: How do I check the status and enable the Ubuntu SSH server?

Once the in­stal­la­tion is complete, you can use the following command to check whether the SSH daemon is running as desired:

sudo systemctl status ssh

You should see the entry “active (running)” in the command output when Ubuntu SSH is running. SSH should also be available at every new system start, meaning the entry “vendor preset: enabled” should also be displayed in the “Loaded” line.

You can enter two ad­di­tion­al commands if SSH is still inactive and the automatic start on reboot is not activated:

sudo systemctl enable ssh
sudo systemctl start ssh
Note

Press “q” if you want to exit the SSH status and return to the command line input.

Step 4: How do I open the SSH port?

The network protocol port (TCP port 22) must be enabled to connect to your Ubuntu system through SSH from anywhere. This will allow you to suc­cess­ful­ly establish a remote con­nec­tion with SSH clients like PuTTy.

Ubuntu has its own con­fig­u­ra­tion program for its native firewall, UFW. An ap­pro­pri­ate rule must be set up for this program for SSH com­mu­ni­ca­tion so the port remains open for incoming and outgoing data:

sudo ufw allow ssh
Tip

A closed port is not the only cause of issues with SSH con­nec­tions. There are several other possible problems which can get in the way of es­tab­lish­ing secure SSH con­nec­tions. We’ll tell you how to resolve SSH errors in the Digital Guide.

Step 5: How do I configure the Ubuntu SSH server?

The basic con­fig­u­ra­tion of OpenSSH is suitable for secure remote con­nec­tions to your Ubuntu system. You could still customize the default settings, such as choosing a different port for com­mu­ni­ca­tion, spec­i­fy­ing an internet protocol version, or disabling TCP for­ward­ing.

The central con­fig­u­ra­tion file for the Ubuntu SSH package is the sshd_config file. Open this file with the text editor (in this case, nano) of your choice to make any changes:

sudo nano /etc/ssh/sshd_config

Customize the config contents as you wish and save the changes before closing. Then restart OpenSSH to apply the ad­just­ments:

sudo service ssh restart
Tip

Setting up SSH is worth it if you plan to use an Ubuntu FTP server. This will offer the secure FTP variant SFTP which was mentioned earlier.

Go to Main Menu