Setting up Ubuntu Server 14.04 LTS

Install

This guide is primarily for my own reference; I run a basic server at home for Git repositories and test sites.

My preference is to run the Long Term Support version of Ubuntu Server. For my new machine I’ll be running 14.04 LTS which will have 5 years of support, so until 2019.

Basically I want to set it up and forget about it – what I don’t want to forget is how it’s set up.


Network

First things first – because this is a server and will primarily be accessed by applications and via SSH/sFTP, let’s make a few networking changes.

Static IP address

To make life easier I want the server to have a static IP address that is easy to remember – I have chosen 192.168.1.150

This number is based on my Plusnet routers addressing of 192.168.1.254

iface eth0 inet static
                address  192.168.1.150
                netmask  255.255.255.0
                gateway  192.168.1.254
                dns-nameservers  8.8.8.8  8.8.4.4

The snippet above is placed in your interfaces configuration:

sudo vi /etc/network/interfaces

This was based on the information from the Unixmen page:

To restart your interface use:

sudo ifdown eth0 && sudo ifup eth0

Your new IP address should be active. If not then you can also try rebooting the machine.

sudo reboot

SSH

From another machine you can log in to your server using OpenSSH as installed during the Ubuntu installation.

Log in

From Terminal:

ssh username@192.168.1.150

Type in your password when it prompts you and agree to any other messages.

Passwordless entry

Generate your key on a client machine, in my case a Mac Pro, though this is pretty much the same as most Linux distributions:

ssh-keygen -t rsa -b 4096

Follow the key generation instructions until you are returned to the command prompt.

To transfer the key to the servers authorised hosts file use the command below:

cat ~/.ssh/id_rsa.pub | ssh username@192.168.1.150 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"

This key can now also be used in applications such as Filezilla and Tower 2 as well.

Now that we have access to our server remotely and it can use passwordless entry, we can disable password access in the SSH config file:

sudo vi /etc/ssh/sshd_config

Change the value of the line below to:

PasswordAuthentication no

To apply the new configuration, restart the SSH server:

sudo service ssh restart

Logging more detail

To log more detail about what SSH is doing, change the value of the line below to:

LogLevel VERBOSE

To apply the new configuration, restart the SSH server:

sudo service ssh restart

To view the log use:

sudo vi /var/log/auth.log

 

Commands useful with SSH

Turn the machine off – shutting down and power off:

sudo shutdown -h now

Reboot the machine – shutting down and restart:

sudo reboot

Determine where you are in the file structure:

pwd

Clear the terminal window:

clear

LAMP

 


Git

Open Terminal and run the following command:

sudo apt-get install git-core

You’ll need to create a Git configuration file in your home directory – I’ll use vi, because it’s just so user friendly:

sudo vi ~/.gitconfig

You should now be starting from a fresh/empty file, close vi and run the following commands to add details to your configuration file:

git config --global user.name "gitUserName"
git config --global user.email user.email@domain.co.uk

If you use GitHub use the same details you use to access the web site. Git is now installed and your user details should be saved in the configuration file.

Get the latest updates

Adding the latest version of Git from their package repository – useful on Ubuntu LTS versions where the Ubuntu Universe version is older than the Git version:

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get upgrade

Mirror existing repositories

Mirroring your existing repositories to the new server

Leave a Reply