Giunsa ang Pag-install sa Samba4 sa CentOS 7 alang sa Pagpakigbahin sa File sa Windows


Sa among katapusan nga artikulo, among gipakita kung giunsa ang pag-install sa Samba4 sa Ubuntu alang sa sukaranan nga pagpaambit sa file tali sa mga sistema sa Ubuntu ug mga makina sa Windows. Diin among gitan-aw ang pag-configure sa anonymous (unsecure) ingon man luwas nga pagpaambit sa file.

Dinhi, among ihulagway kung giunsa ang pag-install ug pag-configure sa Samba4 sa CentOS 7 (nagtrabaho usab sa RHEL 7) alang sa sukaranan nga pagpaambit sa file tali sa ubang mga sistema sa Linux ug mga makina sa Windows.

Importante: Sugod gikan sa bersyon 4.0, ang Samba mahimong modagan isip Samba4 Active Directory Domain Controller, nga naglakip sa kritikal nga mga hilisgutan alang sa Ubuntu, CentOS, ug Windows.

I-install ang Samba4 sa CentOS 7

1. Una i-install ang Samba4 ug gikinahanglan nga mga pakete gikan sa default nga CentOS repository gamit ang yum package manager tool sama sa gipakita.

# yum install samba samba-client samba-common

2. Human ma-install ang mga pakete sa samba, tugotan ang mga serbisyo sa samba pinaagi sa system firewall nga adunay kini nga mga mando.

# firewall-cmd --permanent --zone=public --add-service=samba
# firewall-cmd --reload

Susiha ang Windows Machine Workgroup Settings

3. Sa dili ka pa mopadayon sa pag-configure sa samba, siguroha nga ang Windows machine anaa sa samang workgroup nga ma-configure sa CentOS server.

Adunay duha ka posible nga paagi sa pagtan-aw sa mga setting sa Windows machine workgroup:

  • Pag-right click sa \This PC o \My Computer” → Properties → Advanced system settings → Computer Name.

  • Sa laing paagi, ablihi ang cmd prompt ug padagana ang mosunod nga sugo, unya pangitaa ang \workstation domain sa output sama sa gipakita sa ubos.

>net config workstation

Pag-configure sa Samba4 sa CentOS 7

4. Ang nag-unang samba configuration file mao ang /etc/samba/smb.conf, ang orihinal nga file nag-uban sa pre-configuration settings nga nagpatin-aw sa lain-laing mga configuration direktiba aron mogiya kanimo.

Apan, sa wala pa i-configure ang samba, gisugyot ko nga mag-backup ka sa default file nga sama niini.

# cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

Dayon, ipadayon ang pag-configure sa samba alang sa wala mailhi ug luwas nga mga serbisyo sa pagpakigbahin sa file sama sa gipatin-aw sa ubos.

5. Una paghimo sa gipaambit nga direktoryo diin ang mga file itago sa server ug ibutang ang angay nga mga pagtugot sa direktoryo.

# mkdir -p /srv/samba/anonymous
# chmod -R 0775 /srv/samba/anonymous
# chown -R nobody:nobody /srv/samba/anonymous

Usab, kinahanglan nimo nga usbon ang konteksto sa seguridad sa SELinux alang sa gipaambit nga direktoryo sa samba sama sa mosunod.

# chcon -t samba_share_t /srv/samba/anonymous

6. Sunod, ablihi ang samba configuration file para sa pag-edit, diin mahimo nimong usbon/idugang ang mga seksyon sa ubos uban ang katugbang nga mga direktiba.

# vi /etc/samba/smb.conf
[global]
	workgroup = WORKGROUP
	netbios name = centos
	security = user
[Anonymous]
	comment = Anonymous File Server Share
	path = /srv/samba/anonymous
	browsable =yes
	writable = yes
	guest ok = yes
	read only = no
	force user = nobody

7. Karon pamatud-i ang kasamtangan nga mga setting sa samba pinaagi sa pagpadagan sa sugo sa ubos.

# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
	netbios name = centos
	printcap name = cups
	security = USER
	idmap config * : backend = tdb
	cups options = raw
[homes]
	comment = Home Directories
	browseable = No
	inherit acls = Yes
	read only = No
	valid users = %S %D%w%S
[printers]
	comment = All Printers
	path = /var/tmp
	browseable = No
	printable = Yes
	create mask = 0600
[print$]
	comment = Printer Drivers
	path = /var/lib/samba/drivers
	create mask = 0664
	directory mask = 0775
	write list = root
[Anonymous]
 	comment = Anonymous File Server Share
	path = /srv/samba/anonymous
	force user = nobody
	guest ok = Yes
	read only = No

8. Sa kataposan, sugdi ug palihoka ang mga serbisyo sa samba nga awtomatik nga magsugod sa sunod nga boot ug ipadapat usab ang mga kausaban sa ibabaw aron matuman.

# systemctl enable smb.service
# systemctl enable nmb.service
# systemctl start smb.service
# systemctl start nmb.service

9. Karon sa makina sa Windows, ablihi ang \Network gikan sa bintana sa Windows Explorer, dayon i-klik ang CentOS host, o kaha sulayi nga ma-access ang server gamit ang IP address niini (gamit ang ifconfig command aron makakuha og IP address).

e.g. \2.168.43.168.

10. Sunod, ablihi ang Anonymous nga direktoryo ug pagsulay sa pagdugang sa mga file didto aron ipaambit sa ubang mga tiggamit.

I-setup ang Samba4 Secure File Sharing

11. Una magsugod pinaagi sa paghimo sa usa ka grupo sa samba nga sistema, unya idugang ang mga tiggamit sa grupo ug magbutang ug password alang sa matag user nga sama niini.

# groupadd smbgrp
# usermod tecmint -aG smbgrp
# smbpasswd -a tecmint

12. Unya paghimo ug usa ka luwas nga direktoryo diin ang gipaambit nga mga file tipigan ug ibutang ang angay nga mga pagtugot sa direktoryo nga adunay konteksto sa seguridad sa SELinux para sa samba.

# mkdir -p /srv/samba/secure
# chmod -R 0770 /srv/samba/secure
# chown -R root:smbgrp /srv/samba/secure
# chcon -t samba_share_t /srv/samba/secure

13. Sunod ablihi ang configuration file para sa pag-edit ug usba/idugang ang seksyon sa ubos uban ang katugbang nga mga direktiba.

# vi /etc/samba/smb.conf
[Secure]
	comment = Secure File Server Share
	path =  /srv/samba/secure
	valid users = @smbgrp
	guest ok = no
	writable = yes
	browsable = yes

14. Pag-usab, pamatud-i ang samba configuration settings pinaagi sa pagpadagan sa mosunod nga sugo.

$ testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
	netbios name = centos
	printcap name = cups
	security = USER
	idmap config * : backend = tdb
	cups options = raw
[homes]
	comment = Home Directories
	browseable = No
	inherit acls = Yes
	read only = No
	valid users = %S %D%w%S
[printers]
	comment = All Printers
	path = /var/tmp
	browseable = No
	printable = Yes
	create mask = 0600
[print$]
	comment = Printer Drivers
	path = /var/lib/samba/drivers
	create mask = 0664
	directory mask = 0775
	write list = root
[Anonymous]
 	comment = Anonymous File Server Share
	path = /srv/samba/anonymous
	force user = nobody
	guest ok = Yes
	read only = No
[Secure]
	comment = Secure File Server Share
	path = /srv/samba/secure
	read only = No
	valid users = @smbgrp

15. I-restart ang mga serbisyo sa Samba aron magamit ang mga pagbag-o.

# systemctl restart smb.service
# systemctl restart nmb.service

16. Adto sa Windows machine, ablihi ang \Network gikan sa bintana sa Windows Explorer, dayon i-klik ang CentOS host, o kaha sulayi nga ma-access ang server gamit ang IP address niini.

e.g. \2.168.43.168.

Gihangyo ka nga ihatag ang imong username ug password aron maka-login sa CentOS server. Kung nakasulod ka sa mga kredensyal, i-klik ang OK.

17. Sa higayon nga malampuson ka nga maka-log in, imong makita ang tanang samba shared directories. Karon luwas nga ipaambit ang pipila ka mga file sa ubang gitugotan nga mga tiggamit sa network pinaagi sa paghulog niini sa Secure directory.

Mahimo usab nimo tan-awon kining mapuslanon nga mga artikulo bahin sa pagpaambit sa Samba file sa usa ka network.

  1. Unsaon Pag-mount/Pagtangtang sa Lokal ug Network (Samba & NFS) Filesystems sa Linux
  2. Paggamit sa mga ACL (Access Control Lists) ug Pag-mount sa Samba/NFS Shares
  3. Unsaon Pag-ayo ang SambaCry Vulnerability (CVE-2017-7494) sa Linux Systems

Sa kini nga giya, gipakita namon kanimo kung giunsa ang pag-setup sa Samba4 alang sa dili mailhan ug luwas nga pagpaambit sa file tali sa CentOS ug uban pang mga sistema sa Linux ingon man mga makina sa Windows. Ipaambit ang bisan unsang mga hunahuna kanamo pinaagi sa seksyon sa komento sa ubos.