Configuring SSH on Ubuntu
Once you have installed an OpenSSH server,
sudo apt-get install openssh-server
you will need to configure it by editing the sshd_config file in the /etc/ssh directory.
sshd_config is the configuration file for the OpenSSH server. ssh_config is the configuration file for the OpenSSH client. Make sure not to get them mixed up.
First, make a backup of your sshd_config file by copying it to your home directory, or by making a read-only copy in /etc/ssh by doing:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults sudo chmod a-w /etc/ssh/sshd_config.factory-defaults
Creating a read-only backup in /etc/ssh means you’ll always be able to find a known-good configuration when you need it.
Once you’ve backed up your sshd_config file, you can make changes with any text editor, for example;
sudo gedit /etc/ssh/sshd_config
runs the standard text editor in Ubuntu 12.04 or more recent. For older versions replace “sudo” with “gksudo”. Once you’ve made your changes (see the suggestions in the rest of this page), you can apply them by saving the file then doing:
sudo restart ssh
If you get the error, “Unable to connect to Upstart”, restart ssh with the following:
sudo systemctl restart ssh
Configuring OpenSSH means striking a balance between security and ease-of-use. Ubuntu’s default configuration tries to be as secure as possible without making it impossible to use in common use cases. This page discusses some changes you can make, and how they affect the balance between security and ease-of-use. When reading each section, you should decide what balance is right for your specific situ