ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
SSH (Secure Shell) က remote computer တစ်ခုကို encrypted connection ဖြင့် login ဝင်ပြီး command run ခွင့်ပေးတဲ့ protocol ပါ — ssh username@server-ip ပုံစံနဲ့ ချိတ်ဆက်ပါတယ်, password ရိုက်ရနိုင်သလို SSH key (password မလိုတဲ့ authentication method) နဲ့လည်း ဝင်နိုင်ပါတယ်။ SSH key ဆိုတာ key pair (public + private) ဖြင့် အလုပ်လုပ်ပါတယ် — private key ကို ကိုယ့် computer ထဲမှာပဲ ဆက်ထားရမယ်, public key ကို server ဆီ ကူးပေးထားရမယ်, private key ဖိုင်ကို လုံးဝ တစ်ယောက်ဆီမှ မမျှဝေရပါ (private key = ကိုယ့်အိမ်သော့)။ ssh-keygen က key pair အသစ် ဖန်တီးဖို့ command ပါ, ssh-copy-id ကတော့ public key ကို server ဆီ ကူးပို့ဖို့ command ပါ။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
AWS, DigitalOcean, GCP စတဲ့ cloud server (VPS) ကို provision လုပ်ပြီးလို့ 'server ကို ချိန်းတွေ့မယ်' ဆိုတာနဲ့ ssh root@your-server-ip (ဒါမှမဟုတ် ordinary user) ကို run ပြီး terminal ကနေ တိုက်ရိုက် access ပြုလုပ်ရပါတယ် — ဒီနေရာမှာ authentication method (password vs key) က ချိတ်ဆက်ခြင်းကို ကာကွယ်ပေးတဲ့ လက်ဝှေ့သမားပါ။ SSH key နဲ့ setup ပြီးရင် password ရိုက်စရာမလိုတော့ဘဲ ssh user@ip ချည်း ရိုက်ရုံနဲ့ ချက်ချင်းဝင်လို့ရသွားပါတယ် — password-based login ထက် ပိုလုံခြုံပြီး ပိုအဆင်ပြေပါတယ်။
အတူတူ terminal ထဲ စမ်းမယ်
ssh alice@203.0.113.10
ssh-keygen -t ed25519 -C "my-email@example.com"
ssh-copy-id alice@203.0.113.10
ssh alice@203.0.113.10 # password မလို, key နဲ့ တန်းဝင်ပါပြီssh username@server-ip run ရင် remote server ရဲ့ prompt (username@server-hostname:~$) ပြောင်းသွားသည်ကို တွေ့ရမည်။၅ မိနစ် စမ်းကြည့်
ssh-keygen -t ed25519 ကို ကိုယ့် machine ပေါ်မှာ run ကြည့်ပါ (passphrase ကို empty ချန်လို့ရ, စမ်းရုံမို့)။ Key file ~/.ssh/ ထဲမှာ ဘယ်နေရာ ရှိသွားသလဲ ls -la ~/.ssh နဲ့ ကြည့်ပါ။
သတိလေးတစ်ချက်
Server ရဲ့ SSH port (default 22) ကို internet အနှံ့ open ထားပြီး password-only login ခွင့်ပေးထားရင် bot attack များကနေ ပစ်မှတ်ထားခံနိုင်ပါတယ် — SSH key authentication ကို ဦးစားပေးပြီး password login ကို disable လုပ်ထားတာ security best practice ပါ။