zoukankan      html  css  js  c++  java
  • CentOS 7 配置samba 和 autofs

    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
    完成!

    4:自动挂载autofs

    [root@localhost ~]# yum install autofs

    [root@localhost ~]# vim /etc/auto.master(主配置文件添加挂载目录的上一级目录 (空格)子配置文件目录)

       /media /etc/iso.misc

    [root@localhost ~]# vim /etc/iso.misc(子配置文件添加    挂载目录(空格)-文件系统类型,权限信息(空格):被挂载目录)

      iso -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

    测试,完成!

    如挂载smb服务器

    [root@localhost ~]# yum install autofs

    [root@localhost ~]# vim /etc/auto.master

       /smb /etc/smb.misc

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

      smbroot -fstype=cifs,username=alex,password=alex ://192.168.0.188/smbroot

    测试,完成!

    注意事项

    1:注意被挂载目录冒号的位置。

    2:挂载超时时间设置在 /etc/sysconfig/autofs

      DEFAULT_TIMEOUT=300

  • 相关阅读:
    打印九九乘法表
    PAT (Basic Level) Practice (中文) 1091 N-自守数 (15分)
    PAT (Basic Level) Practice (中文)1090 危险品装箱 (25分) (单身狗进阶版 使用map+ vector+数组标记)
    PAT (Basic Level) Practice (中文) 1088 三人行 (20分)
    PAT (Basic Level) Practice (中文) 1087 有多少不同的值 (20分)
    PAT (Basic Level) Practice (中文)1086 就不告诉你 (15分)
    PAT (Basic Level) Practice (中文) 1085 PAT单位排行 (25分) (map搜索+set排序+并列进行排行)
    PAT (Basic Level) Practice (中文) 1083 是否存在相等的差 (20分)
    PAT (Basic Level) Practice (中文) 1082 射击比赛 (20分)
    PAT (Basic Level) Practice (中文) 1081 检查密码 (15分)
  • 原文地址:https://www.cnblogs.com/languang9801/p/11105428.html
Copyright © 2011-2022 走看看