Monday, May 13, 2019

SAMBA With Multiuser Mounting

                       အခု article ကတော့ SAMBA Server ရဲ့အဆက် mounting the samba share directory with multiuser mount options ဖြစ်ပါတယ်။  Multiuser mount ရဲ့အဓိက လုပ်ဆောင်ချက်ကတော့ default အားဖြင့် samba ရဲ့ credential file အပေါ်မှာ သတ်မှတ်ထား တဲ့ တစ်နည်းအားဖြင့်  samba server ကနေ create လုပ်ထားတဲ့ user ရဲ့ access permission ပေါ်မှာမမှီခိုတော့ ပဲ client စက်မှာရှိတဲ့ local users account တွေက နေတိုက်ရိုက် smb share ကို ခေါ်ယူ သုံးစွဲတာဖြစ်ပါတယ်။ ဘာလို့လဲ ဆိုတော့ multiuser mount မသုံးရင် ဒီ samba share directory ကို client စက်ပေါ်မှ "root" account ကနေပဲ သုံးစွဲခွင့်ရှိပါတယ်။ ဒါ့ကြောင့် တစ်ချို့အခြေနေမှာ root မဟုတ်ပဲ normal user အနေနဲ့ပါ သုံးလို့ရအောင်အတွက်လဲ multiuser mount options ကို အသုံးပြုနိုင်ပါတယ်။



                       ဒီနေရာမှာ multiuser mount သည် "ntlmssp" ဆိုတဲ့ authentication ကို အသုံးပြုပါတယ်။ share ကို access လှမ်းလုပ်ဖို့ရန် အတွက် ကျွန်တော် တို့ #cifscreds ဆိုတဲ့ command ကို အသုံးပြုပါတယ်။ #cifscreds command ကို cifs-utils package က ထောက်ပံ့ပေးထားပါတယ်။ #cifscreds command ရဲ့ အလုပ်လုပ်ပုံကတော့ samba server ရဲ့ multiuser credential မှာပေးထားတဲ့ permission ကို ခနတာ local user ကိုပေးသုံးခွင့်ပြုလိုက်တာဖြစ်ပါတယ်။ ဆိုလိုချင်တာက local user login ၀င်ပြီး #cifscreds နဲ့ Read/Write permission ရထားတဲ့ samba user ကို ခန သုံးလိုက်တဲ့အခါ session တစ်ခုနေနဲ့ ခန ယူသုံးလိုက်တဲ့အခါ log in ၀င်ထားတဲ့ local user account မှာ R/W full access permission ရရှိသွားတာဖြစ်ပါတယ်။ တစ်ကယ်က Theory က သာရှည်ပြီး နည်းနည်းရှုပ်တာပါ setup ပိုင်း က ဘာမှသိပ် မပြောင်းပါဘူး။

Configuring SMB Multiuser
တစ်ကယ်ပြောရင် setup ပိုင်းက တူတူပဲ မို့လို့ သိပ်မကွာတဲ့ အတွက် detail command တွေကို one by one မပြောတော့ဘူး... ပျင်းလို့ပါ :P
အခုအောက်မှာ တွေ့ရတဲ့အတိုင်းဆိုရင် 
1) /devopsshare directory တစ်ခု ဆောက်ထားတယ် အဲ့directory ကိုလိုအပ်တဲ့ SELinux context တွေ နောက် အဲ့ directory ရဲ့  Group (Devops) permission (775) နောက်ပြီး တော့ အခု demo မှာ "devops1" နဲ့ "sysops1" ဆိုပြီး user account နှစ်ခု ရှိတယ်။ devops1 account သည် Devops Group member အဖြစ် full permission ပေးထားပြီး sysops ကိုတော့ read only ပဲ ပေးထားတာဖြစ်ပါတယ်။ နောက်တစ်ပုံ smb.conf မှာ ပေးထားပါတယ်။ 
 2) နောက် user account တွေကို #smbpasswd command ဖြင့် samba authentication ပြုလုပ်ပါတယ်။ 
3) ပုံထဲမှာ မပါပေမယ့် Firewall မှာ samba ကို allow လုပ်ဖို့ မမေ့ပါနဲ့




Client Side Setup
Client ဖက်ခြမ်း က ပြုလုပ်ပုံအဆင့်ဆင့်ကို commands တွေ ပြောပြသွားပါမယ်။ လိုက်ပြီး လုပ်ကြည့်ပါ။
1. #yum -y install cifs-utils (အရင်ဆုံး cifs-utils ကိုသွင်းမယ်)
2. #echo "username=devops1" > /root/smb-multiuser.txt 
    #echo "password=redhat" >> /root/smb-multiuser.txt
( /root အောက်မှာ multiuser mount အတွက် credential file တစ်ခု ဆောက်မယ်။
3. mkdir /mnt/data (directory တစ်ခု ဖွဲ့မယ် smb share ကို mount လုပ်ဖို့ )
4. #vim /etc/fstab > //node01.private.com/devops     /mnt/data       cifs    credentials=/root/smb-multiuser.txt,multiuser,sec=ntlmssp       0 0 
( /etc/fstab ထဲမှာ အခုလိုမျိုး mount ဖို့အတွက် သွားရေးပေးရမယ် )
5. #mount /mnt/data ( mount လုပ်)
6. #su - test1 (local account test1 နဲ့ login လုပ်)
7. #cifscreds add node01.private.com -u devops1
     ( #cifscreds ကိုသုံးပြီး Full permission access ရတဲ့ devops1 ဖြင့် ခနခေါ်သုံးကြည့်)
8. #echo "hello" > /mnt/data/hello.txt ( data ထည့်ကြည့်ပါ permission denied မဖြစ်ရင်ကိုလုပ်ထားတဲ့ setup မှန်ကန်ပါတယ်)
9. sysops နဲ့လဲ သုံးကြည့်ပါ Read Only access ပဲ ရရမှာဖြစ်ပါတယ်။
အောက်မှာ အပေါ်က ပြောပြသွားတဲ့အတိုင်းလုပ်ပြီး ရလာတည့် result ကို ထည့်ပေးထားပါတယ်။ 





That's all for now... Enjoy Reading and Thank You!!!



Share:

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.