Installing Ubuntu Server 14.04.4 online server

Installing Ubuntu Server 14.04.4 online server . In this tutorial, you will learn how to install an online server by using Digital Ocean Virtual private server. This will also cover how to access the Ubuntu server using Putty with SSH configured.

Let’s get started

Register and configure the server

We will use virtual private server. The best service out there I found was Digital Ocean. For only $5 a month, you can have a private server. You will have a full control over it, install a multiple website as you like and many more.

Click this link to register and get $10 credit.
Once you’re logged, under the droplet page click Create Droplet
Under Distributions, find Ubuntu. Select the version 14.04.4 by click the arrow down. Its up to you whether you select x32(32bit) or x64 (64bit). I prefer x64


Choose a size : Select $5/mo. You can upgrade it later if you wish to.
Choose a datacenter region : Select the country closest to your place.
Add you SSH keys : If you have SSH key ready, press New SSH Key and paste you Public there. But if you don’t have idea about it, just leave it. In this tutorial, this section will not be covered. Instead we will install SSH key manually at the end of this tutorial.

Finalize and Create: Choose a hostname. Any name you prefer.
After the droplet is created, the credentials will be send to you email. It will be look like this
Droplet Name: test-droplet
Ip Address: 162.243.171.170
Username: root
Password: aebd02fcf3f39a73

Connecting to your newly created Ubuntu server

Open your Putty and paste the IP Address to the Host name textbox. On Saved Sessions, type MyDemoDroplet and click save.


Click open and a message will pop up, just click Yes.
Login as : root

Copy the password from you email and right click inside your Putty window. This will paste the password and finally press Enter.

Once successfully logged, you will be asked to change your password. Before that, you have to paste again your current password. If wrong current password is entered, Putty will close. If current password is accepted then, you can proceed to enter your new password.



if you wish to change the root password again just simply type sudo passwd root
 

Adding a User

To add a user, copy the below code and paste it in Putty. To paste it, simply right click inside the Putty window.
adduser demo

Give permission to the user
visudo

Find ‘# User privilege specification’. Below root add this line
demo    ALL=(ALL:ALL) ALL
Save it by pressing ctrl+o and exit press ctrl+x
Ensure you have access to the user (demo) directory
sudo chown -R demo /home/demo

Switch to demo user
su demo

Ensure you’re in demo root directory
cd

Create SSH directory
mkdir .ssh

Change permission
chmod 700 .ssh

Create a SSH file named authorized_keys
nano .ssh/authorized_keys
In this file, we will paste the SSH public key. But first we need to create SSH key

Creating SSH Key

Open Putty Key Generator and click Generate

Move your mouse around the window to generate the code. While doing this, the progress bar moves. The faster you move the faster it will finish.

Once finished, on key comment, you can add any word. Its optional. But it’s useful for you to identify this SSH key.

Protect your key by entering Key passphrase.
Click Save private key to your computer, also click Save Public key. Keep this file and never share it to anyone.

Copy the Public SSH key
On the big text box of the Key Generator, you will see long codes starting ssh-rsa …..This is the code we will copy. To do that, right click on that and click Select All. Now right click again and click copy.

Back to Putty again. Right click to it to paste the code. Save it by pressing ctrl+o and exit ctrl+x

Changing the ssh key permission:
chmod 600 .ssh/authorized_keys

Configuring Peagent

This will help you to login to your droplet automatically without asking password. Peagent will use your SSH key as authentication method to access your droplet. This is a secure way to access your server. So just a reminder, never share your SSH key file and your passphrase to anyone.

Run you Peagent software. You will see it in the bottom right of you computer near the clock. Right click it, click add key.

Locate the key where you saved your public key.
It will ask you to enter your passphrase.

*Please remember that auto-login will only work if your Peagent is running and SSH key is loaded.

Testing your SSH

Open your Putty, and select MyDemoDroplet Saved Session and click Load.
On the leftside (Category), find Connection and click Data.

On Auto-login username, type your username demo
Go back to session again (left, under Category) click Save and click Open
You should be seeing the image below. It means Peagent is working

You should be able to login to your server without entering a password

Disable the Root Access

We need to secure our server by disabling the root access. This will block root login to your server. It means you should login to your server using a user you created (demo). Don’t worry after disabling the root access. Once your user account is logged in, you can still switch to root account by typing su root
Lets disable the root access:
sudo nano /etc/ssh/sshd_config
Find the word ‘PermitRootLogin yes’, and change it to no
PermitRootLogin no

Restart SSH service
sudo service ssh restart

Congratulation, you have setup a new online Ubuntu virtual private server.
If you want to use the server to host multiple website, please follow my tutorial about Setup WordPress Multisite on Ubuntu 14.04 with Nigx

0 comments:

Copyright © 2012 My Linux Code