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 အသစ်တစ်ခုကို ဆောက်သုံးရပါမည်။
# 1. Update package list and upgrade system
apt update && apt upgrade -y
# 2. Add new user (replace 'deployer' with your name)
adduser deployer
# 3. Add user to sudo group
usermod -aG sudo deployer
# 4. Switch to new user to verify
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 ကို လုံးဝ ပိတ်ထားခြင်းသည် အလုံခြုံဆုံး ဖြစ်ပါသည်။
# Open SSH daemon config
sudo nano /etc/ssh/sshd_config
# Find and update these settings:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
# Test config and restart SSH service
sudo sshd -t
sudo systemctl restart ssh
Command ရှင်းလင်းချက် (ဖတ်ရှုရန် နှိပ်ပါ)
PermitRootLogin no သည် root အကောင့်ဖြင့် တိုက်ရိုက်ဝင်ရောက်မှုကို ပိတ်ပြီး၊ PasswordAuthentication no သည် password ရိုက်ထည့်၍ ဝင်ခွင့်ကို လုံးဝ ပိတ်ပင်လိုက်ခြင်း ဖြစ်ပါသည်။
3. Install Fail2ban (ကျူးကျော်သူများအား IP ပိတ်ပင်ခြင်း)
မမှန်ကန်သော Login အကြိမ်ကြိမ် ဝင်ရောက်သူများကို အလိုအလျောက် Ban ခြင်း
Fail2ban သည် ဆာဗာ၏ log ဖိုင်များကို စောင့်ကြည့်ပြီး သတ်မှတ်ထားသော အကြိမ်ထက်ကျော်လွန်၍ password မှားရိုက်သူ သို့မဟုတ် မသင်္ကာဖွယ် IP များကို Firewall တွင် အလိုအလျောက် ပိတ်ပင် (Ban) ပေးပါသည်။
# Install fail2ban
sudo apt install fail2ban -y
# Start and enable service on boot
sudo systemctl enable --now fail2ban
# Check fail2ban SSH status
sudo fail2ban-client status sshd
Command ရှင်းလင်းချက် (ဖတ်ရှုရန် နှိပ်ပါ)
Fail2ban တပ်ဆင်ပြီးပါက default jail ဖြင့် SSH brute-force ပြုလုပ်သူများ၏ IP များကို ၁၀ မိနစ်မှ ၂၄ နာရီအထိ အလိုအလျောက် ufw တွင် drop ပြုလုပ်ပေးသွားမည် ဖြစ်ပါသည်။
What is the most secure method to prevent automated brute-force attacks on SSH?
SSH အဝေးထိန်းစနစ်သို့ Bot များ၏ Password ခန့်မှန်းတိုက်ခိုက်မှုများကို ကာကွယ်ရန် အလုံခြုံဆုံး နည်းလမ်းမှာ အဘယ်နည်း?