SSH Key Cryptography နှင့် VPS Server Access Hardening
SSH Key Cryptography အလုပ်လုပ်ပုံ (Public vs Private Key)
Section titled “SSH Key Cryptography အလုပ်လုပ်ပုံ (Public vs Private Key)”SSH Keys စနစ်သည် Asymmetric Cryptography (မညီမျှသော သော့တွဲစနစ်) ပေါ်တွင် အခြေခံထားပါတယ်:
graph LR subgraph Developer Laptop PrivKey["🔑 Private Key (id_ed25519)<br/>မိမိစက်ထဲတွင်သာ အလုံပိတ် သိမ်းဆည်းရမည်"] end
subgraph Cloud VPS Server PubKey["🔓 Public Key (id_ed25519.pub)<br/>~/.ssh/authorized_keys ထဲသို့ ထည့်သွင်းထားသည်"] end
PrivKey -.->|Cryptographic Handshake| PubKey- Private Key (
id_ed25519): ခင်ဗျား၏ Laptop ထဲတွင်သာ အမြဲရှိနေရမည်ဖြစ်ပြီး မည်သူ့ကိုမျှ (GitHub အပါအဝင်) လုံးဝ မပြသရသော လျှို့ဝှက်သော့ ဖြစ်သည်။ - Public Key (
id_ed25519.pub): Server ပေါ်သို့ ပို့ဆောင်သိမ်းဆည်းထားသော အများပြည်သူသုံး သော့ခလောက် ဖြစ်သည်။
အဆင့် ၁: Local Computer တွင် SSH Key Pair ထုတ်ယူခြင်း
Section titled “အဆင့် ၁: Local Computer တွင် SSH Key Pair ထုတ်ယူခြင်း”မိမိ၏ Mac သို့မဟုတ် Windows Terminal တွင် အောက်ပါ Command ကို Run ပါ (RSA ထက် ပိုမိုမြန်ဆန်ပြီး လုံခြုံသော Ed25519 ကို အသုံးပြုပါသည်):
ssh-keygen -t ed25519 -C "admin@takkatho.dev"- ဖိုင်သိမ်းမည့် နေရာ မေးပါက
Enterသာ နှိပ်ပါ။ (Default:~/.ssh/id_ed25519) - Passphrase (စကားဝှက်) မေးပါက အပိုလုံခြုံရေးအတွက် စကားဝှက် ရိုက်ထည့်နိုင်ပါသည် သို့မဟုတ်
Enterနှိပ်၍ ကျော်နိုင်ပါသည်။
အဆင့် ၂: Public Key အား Server ပေါ်သို့ ကူးယူတင်သွင်းခြင်း
Section titled “အဆင့် ၂: Public Key အား Server ပေါ်သို့ ကူးယူတင်သွင်းခြင်း”နည်းလမ်း A: ssh-copy-id ဖြင့် အလွယ်တကူ တင်ခြင်း (Recommended)
Section titled “နည်းလမ်း A: ssh-copy-id ဖြင့် အလွယ်တကူ တင်ခြင်း (Recommended)”ssh-copy-id ubuntu@YOUR_VPS_IPနည်းလမ်း B: Manual ကူးယူနည်း
Section titled “နည်းလမ်း B: Manual ကူးယူနည်း”အကယ်၍ ssh-copy-id မရပါက မိမိစက်မှ Public Key ကို ကူးယူပါ:
cat ~/.ssh/id_ed25519.pubထွက်လာသော ssh-ed25519 AAAA... စာကြောင်းရှည်ကို Copy ကူးပြီး Server ထဲရှိ ~/.ssh/authorized_keys ထဲသို့ သွားရောက် Paste လုပ်ပေးရပါမည်:
# Server ပေါ်တွင်:mkdir -p ~/.sshchmod 700 ~/.sshnano ~/.ssh/authorized_keys# (Paste the public key here)chmod 600 ~/.ssh/authorized_keysအဆင့် ၃: SSH Server Configuration ကို Hardening ပြုလုပ်ခြင်း
Section titled “အဆင့် ၃: SSH Server Configuration ကို Hardening ပြုလုပ်ခြင်း”ယခုအခါ Password မလိုဘဲ SSH Key ဖြင့်သာ Login ဝင်ခွင့်ပြုရန် Server ၏ SSH Config ကို ပြင်ဆင်ပါမည်:
sudo nano /etc/ssh/sshd_configအောက်ပါ Setting ၃ ခုကို ရှာဖွေ၍ ပြင်ဆင်ပါ:
# 1. Root အကောင့်ဖြင့် တိုက်ရိုက် SSH ဝင်ခွင့်ကို ပိတ်မည်PermitRootLogin no
# 2. စကားဝှက် (Password) ဖြင့် Login ဝင်ခွင့်ကို လုံးဝ ပိတ်မည် (Brute-force ကာကွယ်ရန်)PasswordAuthentication no
# 3. Public Key ဖြင့်သာ Login ဝင်ခွင့်ကို ဖွင့်မည်PubkeyAuthentication yesအဆင့် ၄: SSH Service ကို Restart မလုပ်မီ စစ်ဆေးခြင်း
Section titled “အဆင့် ၄: SSH Service ကို Restart မလုပ်မီ စစ်ဆေးခြင်း”# SSH Daemon ကို Restart လုပ်မည်sudo systemctl restart ssh
# (သို့မဟုတ် Ubuntu အချို့တွင်)sudo systemctl restart sshdLocal Computer ရှိ Terminal Tab အသစ်မှ စမ်းသပ် Login ဝင်ခြင်း:
Section titled “Local Computer ရှိ Terminal Tab အသစ်မှ စမ်းသပ် Login ဝင်ခြင်း:”ssh -i ~/.ssh/id_ed25519 ubuntu@YOUR_VPS_IPPassword တောင်းဆိုခြင်း မရှိဘဲ ချက်ချင်း Server ထဲသို့ ရောက်ရှိသွားပါက ခင်ဗျား၏ VPS သည် အောင်မြင်စွာ လုံခြုံသွားပြီ ဖြစ်ပါသည်။
🎯 သင်ခန်းစာ အနှစ်ချုပ်
Section titled “🎯 သင်ခန်းစာ အနှစ်ချုပ်”- အမြဲတမ်း
ed25519SSH Key algorithm ကို သုံးပါ။ - Server ပေါ်တွင်
PasswordAuthentication noသတ်မှတ်ပါ။ - Root User ဖြင့် တိုက်ရိုက် Login မဝင်ဘဲ
sudoUser ဖြင့်သာ ဝင်ရောက်ပါ။
📖
ဒီသင်ခန်းစာ ဖတ်ပြီးပြီလား?
ပြီးမြောက်ကြောင်း မှတ်သားထားရန် အောက်ပါ ခလုတ်ကို နှိပ်ပါ