DevEX - reference for building teams, processes, and platforms
How To Install and Configure Open SSH Server on Ubuntu
1. How To Install and Configure Open SSH Server on Ubuntu
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To......................................................................................................................................................1
Pre-requisites................................................................................................................................................1
Update System..........................................................................................................................................1
Pre-Install – Check Installation Status.......................................................................................................1
Install Package...............................................................................................................................................2
Post-Install – Verify Installation Status.....................................................................................................2
Post-Install - Listen Port............................................................................................................................3
Post-Install – Start Daemon – SSH ............................................................................................................4
Post-Install – Service Self-Test ..................................................................................................................4
Post-Install – Service Listening Status.......................................................................................................4
Self-Test Login to localhost (self)..........................................................................................................5
Configure Firewall – Open SSH Connection..............................................................................................5
Configure Firewall – Restart Service.....................................................................................................5
2. How To Install and Configure Open SSH Server on Ubuntu
1 | P a g e
Overview
In this guide we will go through the steps of installation and configuration of “OpenSSH Server”. In order
to connect to the Ubuntu host remotely and manage the server, openssh-server package has installed and
configured to accept connection.
By default only SSH client is installed to connect to a remote server (minimal install). If the server is
installed with full features enabled, then OpenSSH-server package is installed and enabled.
Applies To
Ubuntu 14.x, tested on Ubuntu 14.04 (minimal install)
Pre-requisites
Internet connection to fetch and install packages.
DHCP or static IP Address enabled or assigned host.
system update.
sudo or root access to the host.
Update System
First thing that you have to ensure that the system is updated with current patches installed. If the patches
are not installed, run the command; Boeing787$
apt-get -y update
Pre-Install – Check Installation Status
Before you install the package, check if the package is already installed on the server, run the command;
dpkg-query -l openssh*
or
dpkg-query -W --showformat='${Package}t ${Status}n' openssh-s*
3. How To Install and Configure Open SSH Server on Ubuntu
2 | P a g e
Install Package
If the package is not installed, next step is to install package “openssh-server”, to install the package run
the command;
apt-get install openssh-server
Post-Install – Verify Installation Status
After installation of the package, we can optionally, validate if the package is installed, to check package
“openssh-server” installation status, run the command;
dpkg-query -l openssh-server
dpkg-query -W --showformat='${Package}t ${Status}n' openssh-s*
4. How To Install and Configure Open SSH Server on Ubuntu
3 | P a g e
Post-Install - Listen Port
Before you start the ssh daemon, you need configure ssh service open the configuration file and
uncomment the port configuration. By default its disabled to listen on any port.
gedit /etc/ssh/ssh_config
Modify port attribute, which will enable the service to listen on port “22” which is also default port for ssh
service as below;
Port 22
After the service restart, this modification will cause ssh service to listen on port 12345 and to connect
from a remote host run command you have to explicitly specify port attribute value “ssh -P 12345
hostname”
5. How To Install and Configure Open SSH Server on Ubuntu
4 | P a g e
Post-Install – Start Daemon – SSH
After configuring the service, next thing is to start ssh service (start the daemon), run the command;
/etc/init.d/ssh start
Post-Install – Service Self-Test
Also, you could do a self-test SSH connectivity of hostname to ensure service is accessible from localhost
as well as external network, if needed, to do a self-test run the command;
telnet `hostname` 22
Post-Install – Service Listening Status
To check if the service is listening, you can also validate it by running the below command; if the “Local
Address:Port” displays “*:22” then the service will accept connections from anywhere.
sudo ss -lnp | grep -E ':22' | grep 'sshd'
6. How To Install and Configure Open SSH Server on Ubuntu
5 | P a g e
Self-Test Login to localhost (self)
To test ssh connection for the server, run the command.
ssh -v localhost or ssh localhost
Configure Firewall – Open SSH Connection
In case your firewall is configured to blocked SSH connection, to allow firewall to ssh connection, run the
command;
ufw allow ssh
Configure Firewall – Restart Service
Optionally, you can restart firewall service, run the command;
service ufw restart