#3 of 11Initial VPS Setup & Security Hardening
BeginnerSecurity⏱️ 10 min

Initial VPS Setup & Security Hardening

VPS စတင်ပြင်ဆင်ခြင်းနှင့် လုံခြုံရေး အဆင့်ဆင့် မြှင့်တင်ခြင်း

Essential first steps on Ubuntu: SSH key authentication, non-root sudo user, disabling root password login, UFW firewall, and Fail2ban.

Ubuntu VPS စတင်ဝယ်ယူပြီးပါက မဖြစ်မနေ လုပ်ဆောင်ရမည့် SSH Key တပ်ဆင်ခြင်း၊ Sudo User အသစ်ဆောက်ခြင်း၊ UFW Firewall နှင့် Fail2ban ထည့်သွင်းခြင်း။

1. Create a Non-Root Sudo User (Root အစား သီးသန့် User ဆောက်ခြင်း)

Server လုံခြုံရေး၏ ပထမဆုံး ခြေလှမ်း

VPS ဝယ်ယူပြီးချိန်တွင် ပေးပို့လာသော root user သည် ဆာဗာ၏ အရာအားလုံးကို ဖျက်ဆီးနိုင်သော အမြင့်ဆုံး အခွင့်အာဏာ ရှိပါသည်။ နေ့စဉ် အလုပ်များအတွက် root အစား sudo အခွင့်အရေးရှိသော သီးသန့် user အသစ်တစ်ခုကို ဆောက်သုံးရပါမည်။

Create Sudo User & Update System
bash
1 $ # 1. Update package list and upgrade system
2 $ apt update && apt upgrade -y
3 $
4 $ # 2. Add new user (replace 'deployer' with your name)
5 $ adduser deployer
6 $
7 $ # 3. Add user to sudo group
8 $ usermod -aG sudo deployer
9 $
10 $ # 4. Switch to new user to verify
11 $ su - deployer
💡Command ရှင်းလင်းချက် (ဖတ်ရှုရန် နှိပ်ပါ)

ဆာဗာရှိ package များကို နောက်ဆုံး update ပြုလုပ်ပြီး deployer အမည်ရှိ user အသစ်ဆောက်ကာ sudo အုပ်စုထဲသို့ ထည့်သွင်းပေးခြင်း ဖြစ်ပါသည်။

2. SSH Hardening & Disable Password Login (Password ဖြင့် Login ဝင်ခြင်း ပိတ်ခြင်း)

Hacker များ၏ Password Brute-force တိုက်ခိုက်မှုကို ကာကွယ်ခြင်း

အင်တာနက်ပေါ်ရှိ bot များသည် Port 22 သို့ ၂၄ နာရီမပြတ် စကားဝှက်များကို ခန့်မှန်းပြီး တိုက်ခိုက် (Brute-force) နေကြပါသည်။ SSH Key Pair ကို အသုံးပြုပြီး Password authentication ကို လုံးဝ ပိတ်ထားခြင်းသည် အလုံခြုံဆုံး ဖြစ်ပါသည်။

Edit /etc/ssh/sshd_config
bash
1 $ # Open SSH daemon config
2 $ sudo nano /etc/ssh/sshd_config
3 $
4 $ # Find and update these settings:
5 $ PermitRootLogin no
6 $ PasswordAuthentication no
7 $ PubkeyAuthentication yes
8 $
9 $ # Test config and restart SSH service
10 $ sudo sshd -t
11 $ sudo systemctl restart ssh
💡Command ရှင်းလင်းချက် (ဖတ်ရှုရန် နှိပ်ပါ)

PermitRootLogin no သည် root အကောင့်ဖြင့် တိုက်ရိုက်ဝင်ရောက်မှုကို ပိတ်ပြီး၊ PasswordAuthentication no သည် password ရိုက်ထည့်၍ ဝင်ခွင့်ကို လုံးဝ ပိတ်ပင်လိုက်ခြင်း ဖြစ်ပါသည်။

3. Install Fail2ban (ကျူးကျော်သူများအား IP ပိတ်ပင်ခြင်း)

မမှန်ကန်သော Login အကြိမ်ကြိမ် ဝင်ရောက်သူများကို အလိုအလျောက် Ban ခြင်း

Fail2ban သည် ဆာဗာ၏ log ဖိုင်များကို စောင့်ကြည့်ပြီး သတ်မှတ်ထားသော အကြိမ်ထက်ကျော်လွန်၍ password မှားရိုက်သူ သို့မဟုတ် မသင်္ကာဖွယ် IP များကို Firewall တွင် အလိုအလျောက် ပိတ်ပင် (Ban) ပေးပါသည်။

Install & Enable Fail2ban
bash
1 $ # Install fail2ban
2 $ sudo apt install fail2ban -y
3 $
4 $ # Start and enable service on boot
5 $ sudo systemctl enable --now fail2ban
6 $
7 $ # Check fail2ban SSH status
8 $ sudo fail2ban-client status sshd
💡Command ရှင်းလင်းချက် (ဖတ်ရှုရန် နှိပ်ပါ)

Fail2ban တပ်ဆင်ပြီးပါက default jail ဖြင့် SSH brute-force ပြုလုပ်သူများ၏ IP များကို ၁၀ မိနစ်မှ ၂၄ နာရီအထိ အလိုအလျောက် ufw တွင် drop ပြုလုပ်ပေးသွားမည် ဖြစ်ပါသည်။

Knowledge Check

What is the most secure method to prevent automated brute-force attacks on SSH?

SSH အဝေးထိန်းစနစ်သို့ Bot များ၏ Password ခန့်မှန်းတိုက်ခိုက်မှုများကို ကာကွယ်ရန် အလုံခြုံဆုံး နည်းလမ်းမှာ အဘယ်နည်း?