Low Orbit Flux Logo 2 F

Ubuntu Server Setup SSH

We start out with a cheat sheet in case you are in a hurry and don't want to read through all of my lengthy descriptions of each step. This will get you started with your Ubuntu Server setup SSH steps (version 16.xx specific).
Jump to - Cheat Sheet
Jump to - Video Instructions
Jump to - Step by Step

Cheat Sheet




Video Instructions

We have video instructions of me setting up SSH on Ubuntu Server. Here is our YouTube video of the process:


Step by Step Written Instructions

Ubuntu Server Versions

This setup is demonstrated on Ubuntu Server 16.04. This should work for versions as old as 15.10. For anything older than that it will be slightly different and you will want to use upstart commands instead. Newer versions including 17.xx should work and these steps should probably still be valid until somday systemd is replaced with something else or the package name changes. Basically, anything current should work.

Getting started

We are going to start off with Ubuntu server running on a VM. It is already logged in on a local console but can’t yet be reached using SSH.

The first thing we are going to do is check the IP address of our server using:
ifconfig -a



First Connection Attempt

Now we know what IP we want to connect to. Next, we are going to try to use SSH to connect to the server from our desktop using:
ssh 10.2.225.97



It doesn’t work.

Lets check if SSHD is running. We’ll use the ps command and pipe the output to grep like this:

ps -ef |grep -i sshd


It isn’t running.

Now lets check if anything is listening on port 22 using netstat like this:

netstat -nltp | grep 22

There is nothing listening on that port.




Install OpenSSH Server

We’re going to need to install OpenSSH Server. We will do this with the apt-get command like this:

sudo apt-get -y install openssh-server



Restart SSHD

Now that the daemon is installed we will restart it with the systemd command, like this:

sudo systemctl restart ssh



Verify

Lets verify that SSHD is up and running.

ps -ef | grep -i sshd

Now lets verify that it is running on port 22.

netstat -nltp | grep 22



Connection Sucessful


Now were going to try connecting with SSH again.

ssh 10.2.225.97 This time it works.



Verify


We can check that we are in fact logged into our server. Thats the right IP and hostname. It looks like we’re in the right place. We have sucessfully logged into our server remotely using SSH.