Enabling SSH on Ubuntu 16.04

By default you are not able to SSH into an Ubuntu 16.04  machine and this blog post describes the steps needed to install SSH server.

Installing OpenSSH Server

To enable logging in from another computer via SSH you need to install a SSH server. To do this you can run the following command. This will install the OpenSSH server for Ubuntu.

sudo apt-get install openssh-server

Once this has installed the OpenSSH server will have been configured and started. At this point you can start using SSH on the machine. By default this will be configured for the default port (22) and will be started each time the machine starts.

Configuring SSH via the config file

The SSH server can be configured by editing its configuration file located at:

/etc/ssh/sshd_config

One of the ways you can improve the security of your server is changing the port SSH runs on. This can be changed by setting the Port setting. If you are changing this it is recommended to set it to a random unusued port above 1024. Doing this doesn’t limit who can access it or provide any inherent security. However most hacking/scanning attempts will automatically try the default port and not try any others.

Another improvement you can make is by disabling SSH via password login. This can be changed with the following SSHD config.

PasswordAuthentication no

Setting PasswordAuthentication to no would only allow login via private key and other more secure authentication methods. It is recommended to only set this up if you have created a private key and verified it works.

Once this has been modified you will need to restart the SSH server for changes to be applied.

How to restart the OpenSSH Server

Any time the configuration server has been modified you will need to restart the SSH server to reload the configuration.  This can easily be done by running the following command.

sudo systemctl restart sshd

Once this has been done any changes to the configuration file will be loaded and applied.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.