How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

July 9, 2018
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

“How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS ” covers the entire process of installing and configuring OpenSSH on Ubuntu Server 18.04 LTS. OpenSSH is the leader in SSH technology, providing the most secure remote communication protocol available to system administrators and enthusiasts alike. OpenSSH encapsulates all communications to and from a remote host in an encryption layer, ensuring that communications remain private and safe from would-be attackers. OpenSSH’s premiere security is in large part due to it being open source and available to security audits at any time, by any auditor. The unrivaled security and ease of use that OpenSSH provides is the reason that industry professionals choose OpenSSH as a means of remote communication over other alternatives. In addition to the security that OpenSSH provides, the communication protocol also offers several authentication methods. OpenSSH is developed and maintained by developers at the OpenBSD Project and is available under a BSD-style license.

Installing and configuring OpenSSH on an Ubuntu Server 18.04 LTS system is easy and straight-forward. To simplify the process for future installations, VirtualZero has created a Bash script that will automate the the process. The script can be downloaded for free from GitHub.

1. Start the Ubuntu Server 18.04 LTS virtual machine and log in. Before installing OpenSSH, update the system by entering the following command:

sudo apt-get update && sudo apt-get upgrade -y
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

2. After the updates complete, OpenSSH Server can be installed. Enter the following command to install OpenSSH Server on the Ubuntu system:

sudo apt-get install openssh-server -y
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

3. Next, we want to start the ssh service and enable it on system startup. To do this, enter the following command:

sudo systemctl start ssh && sudo systemctl enable ssh
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

4. The OpenSSH service is now started and will start automatically when the system boots from now on. Now we need to generate new SSH keys, as the default keys are prone to attacks since they are widely known. First, we will make a directory to house the default SSH keys by entering the following command:

sudo mkdir /etc/ssh/default_keys
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

5. Now that we have a directory to house the default SSH keys, we can move the default keys to it. To move the default SSH keys to their new directory, enter the following command:

sudo mv /etc/ssh/ssh_host_* /etc/ssh/default_keys
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

6. With the default SSH keys safely backed up, we can now generate new SSH keys. To generate the new SSH keys, enter the following command:

sudo dpkg-reconfigure openssh-server
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

7. With our new SSH keys generated, all that is left to do is restart the OpenSSH server to apply the changes. To restart the OpenSSH server, enter the following command:

sudo systemctl restart ssh
How to Install and Configure OpenSSH on Ubuntu Server 18.04 LTS

Congratulations! OpenSSH is successfully installed, configured, and secured on your Ubuntu Server 18.04 LTS machine. Download the Bash script to automate the process for free on GitHub.