CentOS 7 配置samba

1:服务器配置

[root@localhost ~]# yum install -y samba

[root@localhost ~]# pdbedit -a -u alex

[root@localhost ~]# mkdir /home/smbroot
[root@localhost ~]# chown -Rf alex:alex /home/smbroot/
[root@localhost ~]# semanage fcontext -a -t samba_share_t /home/smbroot
[root@localhost ~]# restorecon -Rv /home/smbroot/

[root@localhost ~]# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
tmpreaper_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off
[root@localhost ~]# setsebool -P samba_enable_home_dirs on

[root@localhost ~]# vim /etc/samba/smb.conf

  [global]
  workgroup = SAMBA
  security = user
  server string = Samba Server Version %v
  log file = /var/log/samba/log.%m
  max log size = 50
  passdb backend = tdbsam
  printing = cups
  printcap name = cups
  load printers = yes
  cups options = raw
  [smbroot]
  path = /home/smbroot
  public = no
  writable = yes
  comment = Do not arbitrarily modify the database file

[root@localhost ~]# firewall-cmd --permanent --add-service=samba
success
[root@localhost ~]# systemctl restart firewalld
[root@localhost ~]# systemctl restart smb
[root@localhost ~]# systemctl enable smb

完成!

2:Windows客户顿直接运行 \\192.168.0.188 即可跳出验证登录界面

3:linux客户端命令行配置

[root@localhost ~]# yum install cifs-utils

[root@localhost ~]# vim auth.smb

  username=alex
  password=alex
  domain=SAMBA

[root@localhost ~]# chmod 600 auth.smb

[root@localhost ~]# mkdir /smbshare

[root@localhost ~]# vim /etc/fstab (添加)

  //192.168.10.10/database /database cifs credentials=/root/auth.smb 0 0
完成!

猜你喜欢

转载自www.cnblogs.com/languang9801/p/11105428.html
今日推荐