Initial Server Configuration on Ubuntu Server 14.04

In this tutorial, we are going to describes the first things you should do after fresh installation Ubuntu Server 14.04. There are several configuration steps that you should follow as part of the basic setup of Ubuntu Server 14.04.

Step 1 – Login as Root via SSH

Before login into your ubuntu server, you already know the information about your server’s public IP address and the password for the “root” user’s account. Now, log in into your server with the following command:

ssh root@SERVER_IP_ADDRESS

If you see a message like below, don’t panic. As it is your first connection to your ubuntu server, your computer is telling you that it doesn’t recognize the remote server. Just type “yes” to confirm the authentication.

The authenticity of host '123.123.123.123 (123.123.123.123)' can't be established.
ECDSA key fingerpring is
79:95:46:1a:ab:37:11:8e:86:54:36:38:bb:3c:fa:c0.
Are you sure you want to continue connecting (yes/no)?

Step 2 – Updating Ubuntu Server

After you have logged into your ubuntu server as root, update your ubuntu server repositories by typing the following command.

apt-get update

Type the followong command, if you want to upgrade all existing packages to the latest version. You should hit Y after it asks you if you want to update all packages.

apt-get upgrade

Step 3 – Change Password root user

You are not likely to remember the password that is currently set for your root account. You can change the password to something you will remember more easily by typing:

passwd

It will ask you to enter and confirm your new password. During this process, you will not see anything show up on your screen as you type. This is intentional and is there so that people looking over your shoulder cannot guess your password by the number of characters.

Step 4 – Creating a New Account

In this this tutorial we’ll creates a new user called “ubuntu“, but you can replacing “ubuntu” with whatever username you’d like to use. Now, create the new user account that we will use to log in from now on, to do this by typing the following command:

adduser ubuntu

You will be asked a few questions, starting with the account password.

Step 5 – Giving Your New User Account Sudo Access

Now we need to give your new account acccess to the sudo command, so that you can run commands as root. To do this, run the following command :

visudo

This will open up the file /etc/sudoers. Find a section # user privilege specification, It will look like this:

# User privilege specification
root ALL=(ALL:ALL) ALL

under section root ALL=(ALL:ALL), add the following line :

ubuntu ALL=(ALL:ALL) ALL

Save this file by pressing Ctrl + O and press Enter to confirm you would like to save. Then press Ctrl + X to exit the editor.

Step 6 – Configuring the SSH server

Open the ssh configuration file :

nano /etc/ssh/sshd_config

Find the following section :

Port 22
PermitRootLogin yes

Then change to :

Port 22500
PermitRootLogin no

If you’re done, Save this file by pressing Ctrl + O and press Enter to confirm you would like to save. Then press Ctrl + X to exit the editor.

Port : Although port 22 is the default. In this tutorial we are using port 22500, you can change this to any number between 1025 and 65536.

PermitRootLogin: change this from yes to no to stop future root login. You will now only be logging on as the new user.

Restart SSH server with the following command:

service ssh restart

Log out of the root user by typing command:

logout

and log in back as your new user via ssh:

ssh -p 22500 ubuntu@SERVER_IP_ADDRESS

Remember, if you need to run a command with root privileges, type “sudo”.