💻
ITmatic101 - MY
  • ITmatic101 - နည်းပညာဆိုင်ရာ Blog
  • ☕Linux/BSD
    • Linux distro-hopper ခရီးကြမ်း
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၁)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၂)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၃)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၄)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၅)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၆)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၇)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၈)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၉)
    • လူသုံးများ ရေပန်းစားသော GNU/Linux Distro များ အပိုင်း (၁၀)
    • Manjaro Linux အကြောင်းတစေ့တစောင်း
    • GNU/Linux Desktop Environment များအကြောင်း အပိုင်း (၁)
    • GNU/Linux Desktop Environment များအကြောင်း အပိုင်း (၂)
    • GNU/Linux Desktop Environment များအကြောင်း အပိုင်း (၃)
    • GNU/Linux Desktop Environment များအကြောင်း အပိုင်း (၄)
    • GNU/Linux Desktop Environment များအကြောင်း အပိုင်း (၅)
    • TACACS+ နဲ့ Windows AD ကိုတွဲပြီး အသုံးပြုနည်း – အပိုင်း (၁)
    • TACACS+ နဲ့ Windows AD ကိုတွဲပြီး အသုံးပြုနည်း – အပိုင်း (၂)
    • FreeRADIUS နဲ့ PPPoE Authentication အပိုင်း (၁)
    • FreeRADIUS နဲ့ PPPoE Authentication အပိုင်း (၂)
    • Ubuntu မှာအလုပ်ဖြစ်သော tool နဲ့ application (၁၀) ခုအကြောင်း
    • Docker မိတ်ဆက် အပိုင်း(၁)
    • Docker မိတ်ဆက် အပိုင်း(၂)
    • Docker မိတ်ဆက် အပိုင်း(၃)
    • GNU/Linux ကိုဘာလို့ ပြောင်းသုံးသင့်သလဲ
    • GNU/Linux မှာသုံးတဲ့ CLI ကိုဘယ်လိုခေါ်ကြသလဲ
    • Linux Kernel အကြောင်း သိကောင်းစရာ အပိုင်း (၁)
    • Linux Kernel အကြောင်း သိကောင်းစရာ အပိုင်း (၂)
    • Linux Kernel အကြောင်း သိကောင်းစရာ အပိုင်း (၃)
    • ပြတိုက်ထဲက SysVinit အကြောင်း
    • Open source သင်ခန်းစာများ အပိုင်း(၁)
    • Open source သင်ခန်းစာများ အပိုင်း(၂)
    • လေထုညစ်ညမ်းစပြုလာတဲ့ Linux ရဲ့ Ecosystem
    • အသုံးဝင်သော Linux Certification များအကြောင်း အပိုင်း (၁)
    • အသုံးဝင်သော Linux Certification များအကြောင်း အပိုင်း (၂)
    • အသုံးဝင်သော Linux Certification များအကြောင်း အပိုင်း (၃)
    • အသုံးဝင်သော Linux Certification များအကြောင်း အပိုင်း (၄)
    • အသုံးဝင်သော Linux Certification များအကြောင်း အပိုင်း (၅)
    • Linux မှာသုံးတဲ့ GNU General Public License အကြောင်း အပိုင်း(၁)
    • Linux မှာသုံးတဲ့ GNU General Public License အကြောင်း အပိုင်း(၂)
    • Linux မှာသုံးတဲ့ GNU General Public License အကြောင်း အပိုင်း(၃)
    • Linux မှာသုံးတဲ့ GNU General Public License အကြောင်း အပိုင်း(၄)
    • Open Source ကောက်ကြောင်း – အပိုင်း(၁)
    • Open Source ကောက်ကြောင်း – အပိုင်း( ၂)
    • “မှားတဲ့ဘက်မှာ” – အပိုင်း (၁)
    • “မှားတဲ့ဘက်မှာ” – အပိုင်း (၂)
    • SELinux မိတ်ဆက်
    • Open Source Licenses များအကြောင်း – အပိုင်း (၁)
    • Open Source Licenses များအကြောင်း – အပိုင်း (၂)
    • Keepalived မိတ်ဆက် – အပိုင်း (၁)
    • Keepalived မိတ်ဆက် – အပိုင်း (၂)
    • Linux မှာ package manager တွေကိုဘယ်လိုအသုံးပြုသလဲ
  • 🚀Automation
    • Chef မိတ်ဆက် အပိုင်း(၁)
    • Wireguard ရဲ့ automated workflow
    • အနားမသပ်နိုင် သေးတဲ့ Infrastructure as Code (IaC) – အပိုင်း(၁)
    • အနားမသပ်နိုင် သေးတဲ့ Infrastructure as Code (IaC) – အပိုင်း(၂)
    • အနားမသပ်နိုင် သေးတဲ့ Infrastructure as Code (IaC) - အပိုင်း(၃)
    • အနားမသပ်နိုင် သေးတဲ့ Infrastructure as Code (IaC) - အပိုင်း(၄)
    • ကြုံတွေ့ရသမျှ Network Automation အနုပညာ အပိုင်း(၁)
    • ကြုံတွေ့ရသမျှ Network Automation အနုပညာ အပိုင်း(၂)
    • ကြုံတွေ့ရသမျှ Network Automation အနုပညာ အပိုင်း(၃)
    • Bash နဲ့ Network Configuration Management system တစ်ခုတည်ဆောက်ပုံ – အပိုင်း(၁)
    • Bash နဲ့ Network Configuration Management system တစ်ခုတည်ဆောက်ပုံ – အပိုင်း(၂)
    • FTP/TFTP server ပေါ်မှာ network config တွေကို auto backup လုပ်ပုံ – အပိုင်း (၁)
    • FTP/TFTP server ပေါ်မှာ network config တွေကို auto backup လုပ်ပုံ – အပိုင်း (၂)
    • Kickstart ကိုအသုံးပြုပြီး Custom ISO တွေဖန်တီးပုံ
  • ⚙️Networking
    • အဘယ့်ကြောင့် GNS3
    • ZeroTier မိတ်ဆက်
    • WireGuard အကြောင်းသိကောင်းစရာ
    • Linode VPS မှာကိုယ်ပိုင် Wireguard VPN server တစ်ခုတည်ဆောက်ပုံ
    • အဘယ်ကြောင့် MikroTik
    • VRRP ကို MikroTik မှာ setup လုပ်ပုံ
  • ☁️Virtualisation and Cloud
    • KVM မှာ virtual disk တွေကို ဘယ်လို resize လုပ်လို့ရသလဲ
    • Debian 12 ပေါ်တွင် Proxmox 8 ကိုဘယ်လို integrate လုပ်သလဲ
    • Promox ပေါ်မှာ VM template တွေကို cloud-init သုံးပြီး ဖန်တီးပုံ
    • Custom LXD container templates များကိုဘယ်လို import လုပ်သလဲ
    • Cloud ဆိုသည်မှာ
  • 🍒others
    • Git အကြောင်းသိကောင်းစရာ
    • Home Lab ရှိခြင်း အနုပညာ
    • ကိုယ့်လုံခြုံရေးအတွက် အသုံးပြုသင့်တဲ့ toolkit လေးများ
    • SSH Tunneling အကြောင်းသိကောင်းစရာ
    • အခြေခံ SSH workflow များ
    • SSH Certificate Based Authentication အကြောင်းတစေ့တစောင်း
    • နေ့စဉ်သုံး စိတ်ကြိုက် Application/Software လေးများ
    • Keyboard Size တွေအကြောင်းသိသမျှ
    • သက္ကရာဇ်၂၀၂၀ ခုနှစ်တွင်း နည်းပညာဆိုင်ရာ အမှတ်တရလေးများ
    • သက္ကရာဇ်၂၀၂၁ ခုနှစ်တွင်း နည်းပညာဆိုင်ရာ အမှတ်တရလေးများ
    • Storage အကြောင်းတစေ့တစောင်း – အပိုင်း(၁)
    • Storage အကြောင်းတစေ့တစောင်း – အပိုင်း(၂)
    • Storage အကြောင်းတစေ့တစောင်း – အပိုင်း(၃)
    • Storage အကြောင်းတစေ့တစောင်း – အပိုင်း(၄)
    • Storage အကြောင်းတစေ့တစောင်း – အပိုင်း(၅)
    • အင်တာနက်မြန်မာစာ ယူနီကုဒ်ဇော်ဂျီ ပြဿနာ
    • CyanogenMod မိတ်ဆက် အပိုင်း(၁)
    • WikiLeaks ဆိုသည်မှာ အပိုင်း (၁)
    • WikiLeaks ဆိုသည်မှာ အပိုင်း (၂)
    • WikiLeaks ဆိုသည်မှာ အပိုင်း (၃)
  • 💀OffSec
    • ခုတ်မယ် ထစ်မယ် ပါးပါးလှီးမယ် OpenSSL
Powered by GitBook
On this page
  • Key based authentication ပြဿနာ
  • Key distribution နဲ့ management အခက်အခဲ
  • မလုံလောက်သေးတဲ့ လုံခြုံရေး
  • SSH certificate based authentication ကိုဘယ်လို configure လုပ်ပုံအဆင့်ဆင့်
  • Server-side တွင် setup လုပ်ပုံ
  • Client-side တွင် setup လုပ်ပုံ
  • Server တခုထပ်ပေါင်းထည့်ခြင်း လုပ်ငန်းစဉ်

Was this helpful?

  1. others

SSH Certificate Based Authentication အကြောင်းတစေ့တစောင်း

Previousအခြေခံ SSH workflow များNextနေ့စဉ်သုံး စိတ်ကြိုက် Application/Software လေးများ

Last updated 7 months ago

Was this helpful?

Linux ကိုစအသုံးပြုတော့မယ်ဆိုတာနဲ့ SSH အကြောင်းကိုအခြေခံအားဖြင့်နားလည်ထားရပါ့မယ်။ SSH မှာဘယ် command ကိုအသုံးပြုပြီးတော့ SSH server daemon ကို setup လုပ်သလဲ၊ sshd_config ကိုဘယ်လိုမျိုးစနစ်တကျလုပ်ရသလဲဆိုတာအပြင်၊ SSH client ဘက်မှာလည်း ဘယ်လို command တွေကိုအသုံးပြုပြီး remote server ထဲကိုဝင်ရသလဲဆိုတာမျိုးကိုတော့ စာရေးသူတို့ သိထားရပါတယ်။ သို့သော် SSH ဟာ remote server ထဲကိုဝင်ဖို့သက်သက်မဟုတ်ပဲနဲ့ OpenSSH suite မှာတခါတည်းပါလာတဲ့ အခြားသော feature တွေလည်းရှိပါတယ်။ ဥပမာဆိုရင် SCP လိုမျိုး file တွေ၊ folder တွေကို local machine ကနေ၊ remote server ထဲကို copy လုပ်တဲ့အခါမှာအသုံးပြုနိုင်တဲ့ utility ဟာ SSH ပေါ်မှာအခြေခံထားပါတယ်။ ပိုပြီးတော့ စိတ်ဝင်စားဖို့ကောင်းတဲ့ အခြားသော SSH tunneling feature တွေလည်းရှိပါတယ်။ SSH tunneling အကြောင်းလေ့လာချင်ရင်တော့ ဒီ link မှာသွားကြည့်လို့ရပါတယ်။ ဒါ့အပြင် မကြာသေးခင်ကမှ အလုပ်ခွင်မှာ အခြားသူတွေ မတူတဲ့ SSH workflow တွေကိုအသုံးပြုနေတာကို သတိထားမိလို့ အဲ့ဒီအကြောင်းကို article တခုရေးဖြစ်ပါသေးတယ်။ အဲ့ဒီထဲမှာ SSH မှာအသုံးပြုနိုင်တဲ့ authentication method တွေအကြောင်းကို ဆွေးနွေးဖြစ်ခဲ့ပါတယ်။ Certificate based authentication ကိုလည်းထည့်သွင်း ဖော်ပြဘူးတာကြောင့် ဒီ article မှာတော့ အဲ့ဒီအကြောင်းတခုတည်းကို ရေးဖို့စိတ်ကူးဖြစ်ခဲ့ပါတယ်။ SSH workflow အကြောင်းကိုဖတ်ချင်ရင်တော့ ဒီ link ကနေသွားပြီးတော့ဖတ်လို့ရပါတယ်။

ပုံမှန်အားဖြင့် SSH မှာ username နဲ့ password ကိုအသုံးပြုနိုင်ပါတယ်။ သို့သော် လုံခြုံရေးအတွက် password ကိုရသလောက်ရှောင်ရှားသင့်ပါတယ်။ ဒီထက်တဆင့်မြင့်ပြီး password အစား SSH public/private key authentication ကိုအသုံးပြုနိုင်ပါတယ်။ Key authentication ဟာ လုံခြုံရေးအရရော၊ အဆင်ပြေမူအတွက်ရောနှစ်ခုလုံးအတွက် အသုံးတည့်နိုင်ပါတယ်။ ပြဿနာက ကြိုတင်ပြင်ဆင်ဖို့အတွက်လုပ်ရတဲ့ လုပ်ငန်းဆောင်တာတွေရှိတာရယ်၊ လုံခြုံရေးအတွက်ဟာကွက်တခုလည်းရှိနေပြန်ပါတယ်။

Key based authentication ပြဿနာ

Key distribution နဲ့ management အခက်အခဲ

SSH ရဲ့ key authentication ကိုအသုံးပြုမယ်ဆိုရင် user တိုင်းဟာ ssh-keygen နဲ့ public/private keys pair တခုရှိဖို့လိုပါတယ်။ ဒီနေရာမှာတော့ ဒီ key pair တွေကိုဘယ်လိုမျိုး manage လုပ်နိုင်သလဲဆိုတာကို အသေးစိတ်မရှင်းလိုပါ။ တစ်ယောက်နဲ့ တစ်ယောက် key ကို manage လုပ်ပုံလည်းကွာခြားနိုင်တာမို့ workflow ပေါ်မှာပဲမူတည်နိုင်ပါတယ်။ ဟုတ်ပြီ... ssh-keygen နဲ့ rsa သို့မဟုတ် ed25519 key အမျိုးအစားတခုကို generate လုပ်ပြီးတာနဲ့ အဲ့ဒီ key pair ထဲ public key ကို ကိုယ် remote ဝင်ချင်တဲ့ server admin ကို share ပေးရပါတယ်။ အဲ့ဒီ public key နဲ့ server admin က user account တခုဖန်တီးပြီးတော့ အဲ့ဒီ account ရဲ့ authorized_keys မှာကြိုပြီးတော့ထည့်ပေးရပါလိမ့်မယ်။ လုပ်ရတဲ့ အဆင့်တွေကအများကြီးမဟုတ်ပေမယ့်လည်း အဲ့ဒီ user ဟာ တခုထပ်ပိုတဲ့ remote server တွေကို remote ဝင်ဖို့အတွက်လိုအပ်ရင်တော့ ဖော်ပြပါ အဆင့်တွေကို နောက် server တလုံးပေါ်မှာလုပ်ရပါလိမ့်မယ်။ စာရေးသူအတွက်မှာတော့ ဒီလိုမျိုး တူညီတဲ့အဆင့်တွေကို ထပ်ခါထပ်ခါလုပ်တဲ့နေရာမှာ သက်ရှိထင်ရှားလူတစ်ယောက်ထပ်စာရင်၊ ဒီကိစ္စမျိုးမှာလူထက်သာတဲ့ computer machine တွေကိုသာ ပိုပြီးတော့ယုံကြည်စိတ်ချပါတယ်။ ဒီအတွက် automation ဟာအဖြေပါ။

နောက်တခုက... server တွေကို အကြောင်းအမျိုးမျိုးကြောင့် rebuild လုပ်တဲ့အခါမှာ အဲ့ဒီ key တွေကိုလည်းပြန်ပြီးတော့ user account တွေနဲ့ အတူတူပြန် configure လုပ်ရပါတယ်။ Git လိုမျိုး version control system တခုကို အသုံးမပြုဘူးဆိုရင် ဘယ် key ဟာဖြင့် ဘယ် user အတွက် up-to-date ဖြစ်သလဲဆိုတာမျိုး တခုချင်းစီလိုက်စစ်ဆေးရပါလိမ့်မယ်။ Automation ကိုသုံးလို့ရပေမယ့်လည်း စနစ်တကျတည်ဆောက်တဲ့ automation ဖြစ်ဖို့လိုပါလိမ့်မယ်။ ဒီလိုမှမဟုတ်ရင် အမှားများကာ troubleshoot ခဏခဏလုပ်ရလို့ အချိန်တွေကုန်ပြီး စိတ်ပင်ပန်းရလို့ automation ဆိုတဲ့ဟာကြီးကို မယုံကြည်လို့ မသုံးတော့တဲ့ culture တခုပေါက်ဖွားလာပါလိမ့်မယ်။ ဒါဟာ organisation တခုအတွက် မကောင်းတဲ့ လက္ခဏာတခုပါ။

မလုံလောက်သေးတဲ့ လုံခြုံရေး

SSH ရဲ့ key based authentication မှာ TOFU (Trust On First Use) ဆိုတဲ့ model ကိုသုံးပါတယ်။ ဆိုလိုရင်းက ပထမဆုံးတခေါက်မှာ SSH နဲ့ key authentication လုပ်တဲ့အခါ အဲ့ဒီ remote host ကို known_hosts ထဲမှာထည့်မလားမေးပါလိမ့်မယ်။ စာရေးသူ အပါအဝင် အခြားသော sysadmin တွေဟာ လုံလောက်တဲ့ verification မလုပ်ပဲနဲ့ yes လိုပဲ အလွယ်ဖြေတတ်ကြပါတယ်။ ထိုအတူ အဲ့ဒီ server တွေကို rebuild လုပ်တာပဲဖြစ်ဖြစ်၊ re-IP လုပ်တာပဲဖြစ်ဖြစ် known_hosts ထဲက fingerprint တွေမတူတာဖြစ်ပါတယ်။ အဲ့ဒီအခါမှာ SSH က man-in-the-middle (MITM) attack ဆိုပြီး false positive alert ကိုပြပါတယ်။ သေချာပေါက်သိလို့ match မဖြစ်တဲ့ fingerprint ကိုဖယ်ပြီး ပြန်ထည့်လို့ရနိုင်ပေမယ့် လုံလောက်တဲ့ verification မရှိပဲနဲ့ အလွယ်တကူပြန်ထည့်တတ်ပါတယ်။ ဒါကြောင့် adversary တွေဘက်က အဲ့ဒီအားနည်းချက်တွေကို အခွင့်ကောင်းယူပြီး exploit လုပ်ချင်ကလုပ်လို့ရနိုင်ပါတယ်။

SSH certificate based authentication ကိုဘယ်လို configure လုပ်ပုံအဆင့်ဆင့်

ဒီ labကို တည်ဆောက်ဖို့အတွက် စာရေးသူ LXC container နှစ်ခုကိုအသုံးပြုပါ့မယ်။ တခုကို server ကိုခေါ်ပြီး၊ နောက်တခုကိုတော့ client လို့ပဲအလွယ်ခေါ်လိုက်ပါ့မယ်။ စာရေးသူရဲ့ host machine ကိုတော့ certificate authority (CA) အနေနဲ့အသုံးပြုပြီး demo လုပ်ပြသွားပါ့မယ်။

Server-side တွင် setup လုပ်ပုံ

  • ပထမဆုံးလိုအပ်တဲ့ LXC container တွေကိုအရင်ဆုံးဖန်တီးလိုက်ရအောင်။

tyla@e32:~$ lxc launch ubuntu:22.04 server
Creating server
Starting server
tyla@e32:~$ lxc launch ubuntu:22.04 client
Creating client
Starting client
tyla@e32:~$ lxc list
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
|  NAME  |  STATE  |        IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS |
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| client | RUNNING | 10.93.72.162 (eth0) | fd42:1162:4742:8be6:216:3eff:fef9:3b76 (eth0) | CONTAINER | 0         |
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| server | RUNNING | 10.93.72.126 (eth0) | fd42:1162:4742:8be6:216:3eff:fea1:d898 (eth0) | CONTAINER | 0         |
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
  • နောက်အဆင့်အနေနဲ့ host machine ပေါ်မှာ certificate authority (CA) အတွက်အောက်ပါအတိုင်းပြင်ဆင်ပေးရပါလိမ့်မယ်။

tyla@e32:~$ mkdir ca
tyla@e32:~$ cd ca
tyla@e32:~/ca$ ssh-keygen -t rsa -f ca_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ca_key
Your public key has been saved in ca_key.pub
The key fingerprint is:
SHA256:Pt2Cios3FkNLU770czquXMVk99Fu2ksJwr8IIPRVJNc tyla@e32
The key's randomart image is:
+---[RSA 3072]----+
|         ..+.    |
|      .   +  E . |
|     +   .o . . .|
|    = + .+.. . o |
|   o = =S oo .. o|
|    + o.++..o .+.|
|     o  ==o ...o.|
|   .+o oo.... o .|
|  .ooo+o.. . . . |
+----[SHA256]-----+
tyla@e32:~/ca$ ll
total 16
drwxrwxr-x  2 tyla tyla 4096 Oct  7 17:41 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 17:40 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
  • ca_key အဆင်သင့်ဖြစ်ပြီဆိုတာနဲ့ ca_key.pub public key file ကို server ရဲ့ /etc/ssh/ directory မှာသွားထည့်ပေးပြီး၊ /etc/ssh/sshd_config file ထဲမှာ TrustedUserCAKeys /etc/ssh/ca_key.pub ဆိုတဲ့ဟာနောက်ဆုံးမှာသွားထည့်ပေးလိုက်ပါ။

tyla@e32:~/ca$ scp ca_key.pub ubuntu@10.93.72.126:
The authenticity of host '10.93.72.126 (10.93.72.126)' can't be established.
ED25519 key fingerprint is SHA256:22zfeaYsF1TN9/zLvnxzF/niHzAe/sxb8R+pRt0cn+M.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.93.72.126' (ED25519) to the list of known hosts.
ca_key.pub                                                                                                                                                  100%  562     1.3MB/s   00:00    
tyla@e32:~/ca$ lxc exec server bash
root@server:~# cp /home/ubuntu/ca_key.pub /etc/ssh/
root@server:~# cd /etc/ssh
root@server:/etc/ssh# ll
total 56
drwxr-xr-x  4 root root     15 Oct  7 06:53 ./
drwxr-xr-x 88 root root    176 Oct  7 06:36 ../
-rw-r--r--  1 root root    562 Oct  7 06:53 ca_key.pub
-rw-r--r--  1 root root 505426 Jun 26 13:11 moduli
-rw-r--r--  1 root root   1650 Jun 26 13:11 ssh_config
drwxr-xr-x  2 root root      2 Jun 26 13:11 ssh_config.d/
-rw-------  1 root root    505 Oct  7 06:35 ssh_host_ecdsa_key
-rw-r--r--  1 root root    173 Oct  7 06:35 ssh_host_ecdsa_key.pub
-rw-------  1 root root    399 Oct  7 06:35 ssh_host_ed25519_key
-rw-r--r--  1 root root     93 Oct  7 06:35 ssh_host_ed25519_key.pub
-rw-------  1 root root   2590 Oct  7 06:35 ssh_host_rsa_key
-rw-r--r--  1 root root    565 Oct  7 06:35 ssh_host_rsa_key.pub
-rw-r--r--  1 root root    342 Dec  7  2020 ssh_import_id
-rw-r--r--  1 root root   3254 Jun 26 13:11 sshd_config
drwxr-xr-x  2 root root      3 Oct  2 14:33 sshd_config.d/
root@server:/etc/ssh# echo "TrustedUserCAKeys /etc/ssh/ca_key.pub" >> sshd_config
  • server ရဲ့ /etc/ssh/ directory ကနေ ssh_host_rsa_key.pub ဆိုတဲ့ host public key file ကို CA ရဲ့ ca_key ဆိုတဲ့ private key နဲ့ အောက်မှာပြထားသလိုမျိုး signing လုပ်ပေးဖို့လိုပါလိမ့်မယ်။ ပြီးရင်ထွက်လာတဲ့ cert file ကို /etc/ssh/ အောက်မှာပြန်ထည့်ပြီး HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub ဆိုတဲ့ဟာကို sshd_config မှာထပ်ပေါင်းထည့်ပေးလိုက်ပါ။ sshd_config ထဲမှာ change ထားတဲ့ဟာတွေကို apply လုပ်ဖို့အတွက် systemctl reload sshd ဆိုတဲ့ systemd command နဲ့ ssh server daemon ကို reload လုပ်လိုက်ပါ။

tyla@e32:~/ca$ lxc exec server bash       
root@server:~# cp /etc/ssh/ssh_host_rsa_key.pub /home/ubuntu/
root@server:~# 
exit
tyla@e32:~/ca$ scp ubuntu@10.93.72.126:ssh_host_rsa_key.pub .
ssh_host_rsa_key.pub                                                                                                                                        100%  565     1.4MB/s   00:00    
tyla@e32:~/ca$ ll
total 20
drwxrwxr-x  2 tyla tyla 4096 Oct  7 17:47 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 17:40 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
-rw-r--r--  1 tyla tyla  565 Oct  7 17:47 ssh_host_rsa_key.pub
tyla@e32:~/ca$ ssh-keygen -s ca_key -I Server -V +52w -h ssh_host_rsa_key.pub
Signed host key ssh_host_rsa_key-cert.pub: id "Server" serial 0 valid from 2024-10-07T18:03:00 to 2025-10-06T18:04:04
tyla@e32:~/ca$ ll
total 24
drwxrwxr-x  2 tyla tyla 4096 Oct  7 18:04 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 17:40 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
-rw-r--r--  1 tyla tyla 1822 Oct  7 18:04 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 tyla tyla  565 Oct  7 17:47 ssh_host_rsa_key.pub
tyla@e32:~/ca$ scp ssh_host_rsa_key-cert.pub ubuntu@10.93.72.126:
ssh_host_rsa_key-cert.pub                                                                                                                                   100% 1822     5.4MB/s   00:00    
tyla@e32:~/ca$ lxc exec server bash
root@server:~# cp /home/ubuntu/ssh_host_rsa_key-cert.pub /etc/ssh/
root@server:~# cd /etc/ssh
root@server:/etc/ssh# ll
total 60
drwxr-xr-x  4 root root     16 Oct  7 07:07 ./
drwxr-xr-x 88 root root    176 Oct  7 06:36 ../
-rw-r--r--  1 root root    562 Oct  7 06:53 ca_key.pub
-rw-r--r--  1 root root 505426 Jun 26 13:11 moduli
-rw-r--r--  1 root root   1650 Jun 26 13:11 ssh_config
drwxr-xr-x  2 root root      2 Jun 26 13:11 ssh_config.d/
-rw-------  1 root root    505 Oct  7 06:35 ssh_host_ecdsa_key
-rw-r--r--  1 root root    173 Oct  7 06:35 ssh_host_ecdsa_key.pub
-rw-------  1 root root    399 Oct  7 06:35 ssh_host_ed25519_key
-rw-r--r--  1 root root     93 Oct  7 06:35 ssh_host_ed25519_key.pub
-rw-------  1 root root   2590 Oct  7 06:35 ssh_host_rsa_key
-rw-r--r--  1 root root   1822 Oct  7 07:07 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 root root    565 Oct  7 06:35 ssh_host_rsa_key.pub
-rw-r--r--  1 root root    342 Dec  7  2020 ssh_import_id
-rw-r--r--  1 root root   3292 Oct  7 06:58 sshd_config
drwxr-xr-x  2 root root      3 Oct  2 14:33 sshd_config.d/
root@server:/etc/ssh# echo "HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub" >> sshd_config
root@server:/etc/ssh# systemctl reload sshd

Client-side တွင် setup လုပ်ပုံ

  • အရင်ဆုံးအနေနဲ့ client ရဲ့ .ssh/known_hosts file ထဲမှာ ca_key.pub မှာပါတဲ့ content နဲ့အောက်မှာပြထားတဲ့အတိုင်း ပေါင်းထည့်လိုက်ပါ။

tyla@e32:~/ca$ ssh ubuntu@10.93.72.162
The authenticity of host '10.93.72.162 (10.93.72.162)' can't be established.
ED25519 key fingerprint is SHA256:AIOkykOtO/XyKsnw5XpU8o+rXCNqlkbtJ3yXusBeCcQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.93.72.162' (ED25519) to the list of known hosts.
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Oct  7 07:20:12 UTC 2024

  System load:           2.06
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           37.0 C
  Processes:             26
  Users logged in:       0
  IPv4 address for eth0: 10.93.72.162
  IPv6 address for eth0: fd42:1162:4742:8be6:216:3eff:fef9:3b76

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status



The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@client:~$ vi .ssh/known_hosts
@cert-authority * ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCm+MQ1z48TIUAlcC6XvBnTi6+wyYynpfVN1yxlt1JNrGCg8SCAgvvLaTYPLsriAfvq1mDql+tMqEJ6eATRdNPoqM4RQnrNpy7FCoGL6K4RUrVrlf7FAY6ImeCd07UtBWo5kXdajdBxGAKfk+JN8Dhe9iGIK981LxWlMFYiG81Y6uVFAwR3eqKUXK5Wr0WjGvZHjwzHjS/OCIVYnbontGOI9S8UU4K7wVGpv5+HH63OyRlnog2/66+/afRrL6vRyakMzqeC/Rv3h2vZ+MFq+GOM04O9Uv8TnZRpsAvFeSyPxEp2a7kxs7geDxeGuzdsyvQrn549NFIHiH2X7cdyxbqPzEavBvyLShtVrrY+sfgwLpzT5MoIzmj0CU2w9vJZQXi2VYY/9YxpRkN97Wcspjg7CZ5RdRugwAuiu/cMgV0OScm9qbymv8DF3sFdIFO6cxS96/fc5fxYp8LQoMVRMbjbRdllAodIH5qZ3FelF4BC9sGlzVSBiPOZI1nMX+g2MY0= tyla@e32
  • Client ဘက်မှာလည်းလိုအပ်တဲ့ SSH key pair ကို generate လုပ်ပြီး ရလာတဲ့ public key ကို CA ရဲ့ private key နဲ့ အောက်မှာပြထားသလို signing လုပ်ပေးရပါလိမ့်မယ်။ Signing လုပ်ပြီးလိုရလာတဲ့ cert file ကိုတော့ client ဘက်မှာ ubuntu ဆိုတဲ့ user ရဲ့ .ssh/ directory အောက်မှာပြန်ထည့်ပေးရပါ့မယ်။

ubuntu@client:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ubuntu/.ssh/id_rsa
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ZaRDoGIN0QGgW8YVswkGausUTo3XdEtpn+m/kSWWCpg ubuntu@client
The key's randomart image is:
+---[RSA 3072]----+
|oo*+=+.+o .      |
|ooo=+=o+.o       |
|o=*o=...+ =      |
|+=+.  o  B  .    |
|.+   E .S  + .   |
|o       ..o +    |
| .       ..o     |
|           ..    |
|           ..    |
+----[SHA256]-----+
ubuntu@client:~$ 
logout
Connection to 10.93.72.162 closed.
tyla@e32:~/ca$ scp ubuntu@10.93.72.162:.ssh/id_rsa.pub .
id_rsa.pub                                                                                                                                                  100%  567     1.2MB/s   00:00    
tyla@e32:~/ca$ ll
total 28
drwxrwxr-x  2 tyla tyla 4096 Oct  7 18:27 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 18:06 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
-rw-r--r--  1 tyla tyla  567 Oct  7 18:27 id_rsa.pub
-rw-r--r--  1 tyla tyla 1822 Oct  7 18:04 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 tyla tyla  565 Oct  7 17:47 ssh_host_rsa_key.pub
tyla@e32:~/ca$ ssh-keygen -s ca_key -I Client -n ubuntu -V +52w id_rsa.pub
Signed user key id_rsa-cert.pub: id "Client" serial 0 for ubuntu valid from 2024-10-07T18:27:00 to 2025-10-06T18:28:08
tyla@e32:~/ca$ ll
total 32
drwxrwxr-x  2 tyla tyla 4096 Oct  7 18:28 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 18:06 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
-rw-r--r--  1 tyla tyla 2016 Oct  7 18:28 id_rsa-cert.pub
-rw-r--r--  1 tyla tyla  567 Oct  7 18:27 id_rsa.pub
-rw-r--r--  1 tyla tyla 1822 Oct  7 18:04 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 tyla tyla  565 Oct  7 17:47 ssh_host_rsa_key.pub
tyla@e32:~/ca$ scp id_rsa-cert.pub ubuntu@10.93.72.162:.ssh/
id_rsa-cert.pub                                                                                                                                             100% 2016     6.0MB/s   00:00    
  • အခုဆိုရင်တော့ client ကနေ server ထဲကို SSH နဲ့ certificate based authentication လုပ်ဖို့အတွက် အဆင်သင့်ဖြစ်ပါပြီ။ စမ်းကြည့်လိုက်ရအောင်။

tyla@e32:~/ca$ ssh ubuntu@10.93.72.162
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Oct  7 07:29:15 UTC 2024

  System load:           1.08
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           40.0 C
  Processes:             26
  Users logged in:       0
  IPv4 address for eth0: 10.93.72.162
  IPv6 address for eth0: fd42:1162:4742:8be6:216:3eff:fef9:3b76


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Oct  7 07:20:13 2024 from 10.93.72.1
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@client:~$ ssh ubuntu@10.93.72.126
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Oct  7 07:31:09 UTC 2024

  System load:           1.27
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           39.0 C
  Processes:             26
  Users logged in:       0
  IPv4 address for eth0: 10.93.72.126
  IPv6 address for eth0: fd42:1162:4742:8be6:216:3eff:fea1:d898


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@server:~$ 

အထက်မှာမြင်ရတဲ့အတိုင်းပဲ client machine ကနေ remote server ထဲကို SSH certificate based authentication နဲ့ အောင်မြင်စွာဝင်လိုက်နိုင်ပါပြီ။ ဟုတ်ပြီ... နောက်တဆင့်အနေနဲ့ ပိုပြီး စိတ်ဝင်စားဖို့ကောင်းသွားအောင် နောက်ထပ် server တခုကိုအခုလက်ရှိ lab ထဲမှာထည့်တဲ့ လုပ်ငန်းစဉ်ကိုလေ့လာကြည့်ရအောင်။

Server တခုထပ်ပေါင်းထည့်ခြင်း လုပ်ငန်းစဉ်

  • နောက်ထပ်ပေါင်းထည့်မယ့် server ကိုတော့ server1 လို့ပဲအလွယ်ခေါ်လိုက်ရအောင်။ LXC container တခုကိုအောက်မှာ ဖော်ပြထားတဲ့အတိုင်း အရင်ဖန်တီးပေးလိုက်ပါ။

tyla@e32:~/ca$ lxc launch ubuntu:22.04 server1
Creating server1
Starting server1
tyla@e32:~/ca$ lxc list 
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
|  NAME   |  STATE  |        IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| client  | RUNNING | 10.93.72.162 (eth0) | fd42:1162:4742:8be6:216:3eff:fef9:3b76 (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| server  | RUNNING | 10.93.72.126 (eth0) | fd42:1162:4742:8be6:216:3eff:fea1:d898 (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| server1 | RUNNING | 10.93.72.220 (eth0) | fd42:1162:4742:8be6:216:3eff:fe26:bffb (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
  • အရှေ့မှာလုပ်ဆောင်ခဲ့တဲ့ server-side ဘက်က setup ကိုခပ်သွပ်သွပ်လေးနောက်တခါလုပ်လိုက်ရအောင်ဗျ။ ဘယ်လိုမျိုးလုပ်မလဲဆိုတာကို အောက်မှာကြည့်လိုက်ရအောင်။

tyla@e32:~/ca$ scp ca_key.pub ubuntu@10.93.72.220:
The authenticity of host '10.93.72.220 (10.93.72.220)' can't be established.
ED25519 key fingerprint is SHA256:zomIP3dt9e24mfG4wqMWR5oHPcszxJnSp6YrkQmK5QM.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.93.72.220' (ED25519) to the list of known hosts.
ca_key.pub                                                                                                                                                  100%  562     2.0MB/s   00:00    
tyla@e32:~/ca$ lxc exec server1 bash
root@server1:~# cp /home/ubuntu/ca_key.pub /etc/ssh/
root@server1:~# cd /etc/ssh
root@server1:/etc/ssh# ll
total 57
drwxr-xr-x  4 root root     15 Oct  7 09:58 ./
drwxr-xr-x 88 root root    176 Oct  7 09:53 ../
-rw-r--r--  1 root root    562 Oct  7 09:58 ca_key.pub
-rw-r--r--  1 root root 505426 Jun 26 13:11 moduli
-rw-r--r--  1 root root   1650 Jun 26 13:11 ssh_config
drwxr-xr-x  2 root root      2 Jun 26 13:11 ssh_config.d/
-rw-------  1 root root    505 Oct  7 09:53 ssh_host_ecdsa_key
-rw-r--r--  1 root root    174 Oct  7 09:53 ssh_host_ecdsa_key.pub
-rw-------  1 root root    399 Oct  7 09:53 ssh_host_ed25519_key
-rw-r--r--  1 root root     94 Oct  7 09:53 ssh_host_ed25519_key.pub
-rw-------  1 root root   2602 Oct  7 09:53 ssh_host_rsa_key
-rw-r--r--  1 root root    566 Oct  7 09:53 ssh_host_rsa_key.pub
-rw-r--r--  1 root root    342 Dec  7  2020 ssh_import_id
-rw-r--r--  1 root root   3254 Jun 26 13:11 sshd_config
drwxr-xr-x  2 root root      3 Oct  2 14:33 sshd_config.d/
root@server1:/etc/ssh# echo "TrustedUserCAKeys /etc/ssh/ca_key.pub" >> sshd_config
root@server1:/etc/ssh# cp ssh_host_rsa_key
ssh_host_rsa_key      ssh_host_rsa_key.pub  
root@server1:/etc/ssh# cp ssh_host_rsa_key.pub /home/ubuntu/
root@server1:/etc/ssh# cd /home/ubuntu
root@server1:/home/ubuntu# ll
total 12
drwxr-x--- 4 ubuntu ubuntu    9 Oct  7 09:59 ./
drwxr-xr-x 3 root   root      3 Oct  7 09:53 ../
-rw-r--r-- 1 ubuntu ubuntu  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Jan  6  2022 .bashrc
drwx------ 2 ubuntu ubuntu    3 Oct  7 09:57 .cache/
-rw-r--r-- 1 ubuntu ubuntu  807 Jan  6  2022 .profile
drwx------ 2 ubuntu ubuntu    3 Oct  7 09:53 .ssh/
-rw-r--r-- 1 ubuntu ubuntu  562 Oct  7 09:57 ca_key.pub
-rw-r--r-- 1 root   root    566 Oct  7 09:59 ssh_host_rsa_key.pub
root@server1:/home/ubuntu# chown ubuntu:ubuntu ssh_host_rsa_key.pub 
root@server1:/home/ubuntu# ll
total 12
drwxr-x--- 4 ubuntu ubuntu    9 Oct  7 09:59 ./
drwxr-xr-x 3 root   root      3 Oct  7 09:53 ../
-rw-r--r-- 1 ubuntu ubuntu  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Jan  6  2022 .bashrc
drwx------ 2 ubuntu ubuntu    3 Oct  7 09:57 .cache/
-rw-r--r-- 1 ubuntu ubuntu  807 Jan  6  2022 .profile
drwx------ 2 ubuntu ubuntu    3 Oct  7 09:53 .ssh/
-rw-r--r-- 1 ubuntu ubuntu  562 Oct  7 09:57 ca_key.pub
-rw-r--r-- 1 ubuntu ubuntu  566 Oct  7 09:59 ssh_host_rsa_key.pub
root@server1:/home/ubuntu# 
exit
tyla@e32:~/ca$ scp ubuntu@10.93.72.220:ssh_host_rsa_key.pub .
ssh_host_rsa_key.pub                                                                                                                                        100%  566   951.2KB/s   00:00    
tyla@e32:~/ca$ ssh-keygen -s ca_key -I Server1 -V +52w -h ssh_host_rsa_key.pub
Signed host key ssh_host_rsa_key-cert.pub: id "Server1" serial 0 valid from 2024-10-07T21:00:00 to 2025-10-06T21:01:08
tyla@e32:~/ca$ 
tyla@e32:~/ca$ 
tyla@e32:~/ca$ ll
total 32
drwxrwxr-x  2 tyla tyla 4096 Oct  7 18:28 ./
drwxr-x--- 47 tyla tyla 4096 Oct  7 18:31 ../
-rw-------  1 tyla tyla 2590 Oct  7 17:41 ca_key
-rw-r--r--  1 tyla tyla  562 Oct  7 17:41 ca_key.pub
-rw-r--r--  1 tyla tyla 2016 Oct  7 18:28 id_rsa-cert.pub
-rw-r--r--  1 tyla tyla  567 Oct  7 18:27 id_rsa.pub
-rw-r--r--  1 tyla tyla 1823 Oct  7 21:01 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 tyla tyla  566 Oct  7 21:00 ssh_host_rsa_key.pub
tyla@e32:~/ca$ scp ssh_host_rsa_key ubuntu@10.93.72.220:
scp: stat local "ssh_host_rsa_key": No such file or directory
tyla@e32:~/ca$ scp ssh_host_rsa_key-cert.pub  ubuntu@10.93.72.220:
ssh_host_rsa_key-cert.pub                                                                                                                                   100% 1823     6.7MB/s   00:00    
tyla@e32:~/ca$ lxc exec server1 bash
root@server1:~# cp /home/ubuntu/ssh_host_rsa_key-cert.pub /etc/ssh/
root@server1:~# cd /etc/ssh
root@server1:/etc/ssh# ll
total 60
drwxr-xr-x  4 root root     16 Oct  7 10:02 ./
drwxr-xr-x 88 root root    176 Oct  7 09:53 ../
-rw-r--r--  1 root root    562 Oct  7 09:58 ca_key.pub
-rw-r--r--  1 root root 505426 Jun 26 13:11 moduli
-rw-r--r--  1 root root   1650 Jun 26 13:11 ssh_config
drwxr-xr-x  2 root root      2 Jun 26 13:11 ssh_config.d/
-rw-------  1 root root    505 Oct  7 09:53 ssh_host_ecdsa_key
-rw-r--r--  1 root root    174 Oct  7 09:53 ssh_host_ecdsa_key.pub
-rw-------  1 root root    399 Oct  7 09:53 ssh_host_ed25519_key
-rw-r--r--  1 root root     94 Oct  7 09:53 ssh_host_ed25519_key.pub
-rw-------  1 root root   2602 Oct  7 09:53 ssh_host_rsa_key
-rw-r--r--  1 root root   1823 Oct  7 10:02 ssh_host_rsa_key-cert.pub
-rw-r--r--  1 root root    566 Oct  7 09:53 ssh_host_rsa_key.pub
-rw-r--r--  1 root root    342 Dec  7  2020 ssh_import_id
-rw-r--r--  1 root root   3292 Oct  7 09:59 sshd_config
drwxr-xr-x  2 root root      3 Oct  2 14:33 sshd_config.d/
root@server1:/etc/ssh# echo "HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub" >> sshd_config
root@server1:/etc/ssh# systemctl reload sshd
root@server1:/etc/ssh# 
exit
tyla@e32:~/ca$ lxc list 
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
|  NAME   |  STATE  |        IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| client  | RUNNING | 10.93.72.162 (eth0) | fd42:1162:4742:8be6:216:3eff:fef9:3b76 (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| server  | RUNNING | 10.93.72.126 (eth0) | fd42:1162:4742:8be6:216:3eff:fea1:d898 (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| server1 | RUNNING | 10.93.72.220 (eth0) | fd42:1162:4742:8be6:216:3eff:fe26:bffb (eth0) | CONTAINER | 0         |
+---------+---------+---------------------+-----------------------------------------------+-----------+-----------+
tyla@e32:~/ca$ ssh ubuntu@10.93.72.162
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Oct  7 10:03:20 UTC 2024

  System load:           1.32
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           40.0 C
  Processes:             26
  Users logged in:       0
  IPv4 address for eth0: 10.93.72.162
  IPv6 address for eth0: fd42:1162:4742:8be6:216:3eff:fef9:3b76

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Oct  7 07:29:16 2024 from 10.93.72.1
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@client:~$ ssh ubuntu@10.93.72.220
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Oct  7 10:03:36 UTC 2024

  System load:           1.25
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           39.0 C
  Processes:             26
  Users logged in:       0
  IPv4 address for eth0: 10.93.72.220
  IPv6 address for eth0: fd42:1162:4742:8be6:216:3eff:fe26:bffb


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@server1:~$ 

Server-side မှာလုပ်စရာတွေလုပ်ပြီးတာနဲ့ ရှိပြီးသား client ကနေ ဘာမှထွေထွေထူးထူးလုပ်စရာ မလိုပဲနဲ့ ဒီအတိုင်း SSH နဲ့ဝင်ရောက်နိုင်တာကိုတွေ့ရမှာပါ။ စာရေးသူတို့ အနေနဲ့ client အသစ်တွေထပ်ထည့်ချင်ရင်လည်း client-side မှာလုပ်တဲ့ အဆင့်တွေကိုလုပ်လိုက်ရုံနဲ့ SSH ကိုကောင်းမွန်လုံခြုံစွာ စတင်အသုံးချနိုင်ပါတယ်။

Key based authentication ကို setup လုပ်တာထပ်စာရင်၊ certificate based authentication ကို setup လုပ်ရတာ အဆင့်တွေအများကြီးနဲ့ ရှုပ်ထွေးတယ်လို့ဆိုနိုင်ပေမယ့်လည်း သူ့ရဲ့ workflow ထဲမှာကိုက certificate authority (CA) ကိုအသုံးချပြီးတော့ cyber-security မှာလူသိများ CIA (Confidentiality, Integrity and Availability) model ကိုအသုံးချထားပါတယ်။ ဒါကြောင့်လည်း key based authentication မှာလိုမျိုး TOFU အတွက် တကူးတက manually verify လုပ်စရာမလိုပါ။ Scalability အတွက်လည်း လွန်စွာလွယ်ကူတာကြောင့် လုပ်ငန်းခွင်တွေမှာ အတော်လေးကိုအသုံးတည့်နိုင်ပါတယ်။ အားလုံးအတွက်လည်း ဒီ article ဟာအလွယ်တကူ နားလည်နိုင်ပြီး အသုံးတည့်မယ်လို့ မျှော်လင့်ပါတယ်။

မှတ်မှတ်ရရ ၂၀၀၈ ခုနှစ်တုန်းက SSH key authentication အတွက် CVE တခုရှိခဲ့ဘူးပါတယ်။ Debian OpenSSL Predictable PRNG (CVE-2008-0166) ဆိုပြီးလူသိများပါတယ်။ ထို CVE အကြောင်းကိုအသေးစိတ်သိချင်ရင် ဒီ GitHub link မှာသွားရောက်လေ့လာနိုင်ပါတယ်။ Exploit ကိုဘယ်လိုသုံးသလဲဆိုတာကို နောက် article တခုမှာသပ်သပ်ရေးခဲ့ဘူးပါတယ်။ အဲ့ဒီ article ကိုဖတ်ချင်ရင်တော့ ဒီ link ကနေသွားဖတ်လို့ရပါတယ်။ ဒါကြောင့် SSH key authentication ဆိုတာနဲ့ ပြီးပြည့်စုံအောင် စိတ်မချရသေးပါ။

https://github.com/g0tmi1k/debian-ssh
https://my.itmatic101.com/offsec/khokme-taitme-papalhime-openssl
🍒
https://my.itmatic101.com/others/ssh-tunneling-intro
https://my.itmatic101.com/others/akhyekhan-ssh-workflow-myaa
Page cover image
SSH Key Based Authentication
SSH Certificate Based Authentication