Step by step creating virtual private server (vps) and add default ubuntu user in digital ocean

      5
*

Bạn đang xem: Step by step creating virtual private server (vps) and add default ubuntu user in digital ocean

*

Prerequisites:You should have basic knowledge about:

Basic Linux command line

?Step 1: Create a “droplet” inDigitalOcean($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 vps ip)?Step 2: Login to your VPS via root account

ssh root

Xem thêm: Cách Tìm Phần Mềm Chạy Ẩn - Kiểm Tra Các Phần Mềm Đang Chạy Trên Máy Tính

your_server_ip

?Step 3: Create a default user (let’s named it “ubuntu“). Please remember to never userootaccount for day to day task. Root account is to lớn used just for creating theubuntuuser, after that we will not use root trương mục (at least in most case). đầu vào your password when be asked:

adduser ubuntu

Add “sudo” permission toubuntuuser:

usermod -aG sudo ubuntu

Login toubuntuuser:

su - ubuntu

It should be fine now, from now on you can log in your VPS hệ thống viaubuntuaccount:

ssh ubuntu
your_server_ip

and đầu vào password when be asked. You’re good khổng lồ go!

However, you are recommended to add ssh key for better security và convenient login. Let’s move khổng lồ next steps:?Step 4: Create ssh key in yourVPS

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 yourlocal 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 yourlocal machine:

cat ~/.ssh/id_rsa.pub | pbcopy

(or if you don’t have pbcopy, just xuất hiện the public key (id_rsa.pub) & manually copy it!

Now move lớn theVPS:Edit this file:

~/.ssh/authorized_keys

and địa chỉ cửa hàng the public key content that you copied from your local machine

?Finish!Now you can logout and login to lớn 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