STEP BY STEP CREATING VIRTUAL PRIVATE SERVER (VPS) AND ADD DEFAULT UBUNTU USER IN DIGITAL OCEAN

STEP BY STEP CREATING VIRTUAL PRIVATE SERVER (VPS) AND ADD DEFAULT UBUNTU USER IN DIGITAL OCEAN

Prerequisites:
You should have basic knowledge about:

?Step 1: Create a “droplet” in DigitalOcean ($5/month is enough. Choose backup (+$1) if you build a VPS for production. You will get the VPS IP, such as: 128.199.178.111 (change this to your server ip)
?Step 2: Login to your VPS via root account

ssh root@your_server_ip

?Step 3: Create a default user (let’s named it “ubuntu“). Please remember to never use root account for day to day task. root account is to used just for creating the ubuntu user, after that we will not use root account (at least in most case). Input your password when be asked:

adduser ubuntu

Add “sudo” permission to ubuntu user:

usermod -aG sudo ubuntu

Login to ubuntu user:

su - ubuntu

It should be fine now, from now on you can log in your VPS server via ubuntu account:

ssh ubuntu@your_server_ip

and input password when be asked. You’re good to go!


However, you are recommended to add ssh key for better security & convenient login. Let’s move to next steps:
?Step 4: Create ssh key in your VPS

ssh-keygen

Just hit enter until system finish creating your key pair which are:

~/.ssh/id_rsa
~/.ssh/id_rsa.pub

?Step 5:  Similar with step 4, but this time you create ssh key in your local machine (skip if you already have ssh key)

ssh-keygen

Just hit enter until system finish creating your key pair which are:

~/.ssh/id_rsa
~/.ssh/id_rsa.pub

?Step 6: Copy your public key into the VPS server:
In your local machine:

cat ~/.ssh/id_rsa.pub | pbcopy

(or if you don’t have pbcopy, just open the public key (id_rsa.pub) and manually copy it!

Now move to the VPS:
Edit this file:

~/.ssh/authorized_keys

and add the public key content that you copied from your local machine

Finish! Now you can logout and login to your VPS again, this time it will be logged in automatically without prompt any password:

ssh ubuntu@your_server_ip

Thank you for your reading! Please leave comment if you have any question or idea

Alex

You can share this post!

PHƯƠNG PHÁP PHÂN TÍCH VẤN ĐỀ

5 CÁCH ĐỂ CẢI THIỆN UX TRÊN WEBSITE CỦA BẠN

2 thoughts on “STEP BY STEP CREATING VIRTUAL PRIVATE SERVER (VPS) AND ADD DEFAULT UBUNTU USER IN DIGITAL OCEAN

Leave a Reply

Your email address will not be published. Required fields are marked *