Samba

文件共享

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
yum install samba Loaded plugins: langpacks, product-id, subscription-manager ………………省略部分输出信息……………… Installing: samba x86_64 4.1.1-31.el7 rhel 527 k Transaction Summary =============================================================================== Install 1 Package Total download size: 527 k Installed size: 1.5 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : samba-4.1.1-31.el7.x86_64 1/1 Verifying : samba-4.1.1-31.el7.x86_64 1/1 Installed: samba.x86_64 0:4.1.1-31.el7 Complete! cat /etc/samba/smb.conf # This is the main Samba configuration file. For detailed information about the # options listed here, refer to the smb.conf(5) manual page. Samba has a huge # number of configurable options, most of which are not shown in this example. # # The Official Samba 3.2.x HOWTO and Reference Guide contains step-by-step # guides for installing, configuring, and using Samba: # http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf # # The Samba-3 by Example guide has working examples for smb.conf. This guide is # generated daily: http://www.samba.org/samba/docs/Samba-Guide.pdf # # In this file, lines starting with a semicolon (;) or a hash (#) are # comments and are ignored. This file uses hashes to denote commentary and # semicolons for parts of the file you may wish to configure. # # Note: Run the "testparm" command after modifying this file to check for basic # syntax errors. # ………………省略部分输出信息………………

Samba参数

[global]参数作用
-workgroup-=-MYGROUP#工作组名称
-server-string-=-Samba-Server-Version-%v#服务器介绍信息,参数%v为显示SMB版本号
-log-file-=-/var/log/samba/log.%m#定义日志文件的存放位置与名称,参数%m为来访的主机名
-max-log-size-=-50#定义日志文件的最大容量为50KB
-security-=-user#安全验证的方式,总共有4种
-#share:来访主机无需验证口令;比较方便,但安全性很差-
-#user:需验证来访主机提供的口令后才可以访问;提升了安全性-
-#server:使用独立的远程主机验证来访主机提供的口令(集中管理账户)-
-#domain:使用域控制器进行身份验证-
-passdb-backend-=-tdbsam#定义用户后台的类型,共有3种
-#smbpasswd:使用smbpasswd命令为系统用户设置Samba服务程序的密码-
-#tdbsam:创建数据库文件并使用pdbedit命令建立Samba服务程序的用户-
-#ldapsam:基于LDAP服务进行账户验证-
-load-printers-=-yes#设置在Samba服务启动时是否共享打印机设备
-cups-options-=-raw#打印机的选项
[homes]-#共享参数
-comment-=-Home-Directories#描述信息
-browseable-=-no#指定共享信息是否在“网上邻居”中可见
-writable-=-yes#定义是否可以执行写入操作,与“readonly”相反
[printers]-#打印机共享参数

1 2 3
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf cat /etc/samba/smb.conf

Samba参数

参数作用
[database]共享名称为database
comment-=-Do-not-arbitrarily-modify-the-database-file警告用户不要随意修改数据库
path-=-/home/database共享目录为/home/database
public-=-no关闭“所有人可见”
writable-=-yes允许写入操作

pdbedit命令参数

参数作用
-a_用户名建立Samba账户
-x_用户名删除Samba账户
-L列出账户列表
-Lv列出账户详细信息的列表

  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
id linuxprobe uid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe) pdbedit -a -u linuxprobe new password:此处输入该账户在Samba服务数据库中的密码 retype new password:再次输入密码进行确认 Unix username: linuxprobe NT username: Account Flags: User SID: S-1-5-21-507407404-3243012849-3065158664-1000 Primary Group SID: S-1-5-21-507407404-3243012849-3065158664-513 Full Name: linuxprobe Home Directory: \\localhost\linuxprobe HomeDir Drive: Logon Script: Profile Path: \\localhost\linuxprobe\profile Domain: LOCALHOST Account desc: Workstations: Munged dial: Logon time: 0 Logoff time: Wed, 06 Feb 2036 10:06:39 EST Kickoff time: Wed, 06 Feb 2036 10:06:39 EST Password last set: Mon, 13 Mar 2017 04:22:25 EDT Password can change: Mon, 13 Mar 2017 04:22:25 EDT Password must change: never Last bad password : 0 Bad password count : 0 Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF mkdir /home/database chown -Rf linuxprobe:linuxprobe /home/database semanage fcontext -a -t samba_share_t /home/database restorecon -Rv /home/database restorecon reset /home/database context unconfined_u:object_r:home_root_t:s0-> unconfined_u:object_r:samba_share_t:s0 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_portmapper --> off samba_run_unconfined --> off samba_share_fusefs --> off samba_share_nfs --> off sanlock_use_samba --> off use_samba_home_dirs --> off virt_sandbox_use_samba --> off virt_use_samba --> off setsebool -P samba_enable_home_dirs on vim /etc/samba/smb.conf 1 [global] 2 workgroup = MYGROUP 3 server string = Samba Server Version %v 4 log file = /var/log/samba/log.%m 5 max log size = 50 6 security = user 7 passdb backend = tdbsam 8 load printers = yes 9 cups options = raw 10 [database] 11 comment = Do not arbitrarily modify the database file 12 path = /home/database 13 public = no 14 writable = yes systemctl restart smb systemctl enable smb ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user. target.wants/smb.service' iptables -F service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] yum install cifs-utils Loaded plugins: langpacks, product-id, subscription-manager rhel | 4.1 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package cifs-utils.x86_64 0:6.2-6.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================== Package Arch Version Repository Size =============================================================================== Installing: cifs-utils x86_64 6.2-6.el7 rhel 83 k Transaction Summary =============================================================================== Install 1 Package Total download size: 83 k Installed size: 174 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : cifs-utils-6.2-6.el7.x86_64 1/1 Verifying : cifs-utils-6.2-6.el7.x86_64 1/1 Installed: cifs-utils.x86_64 0:6.2-6.el7 Complete! vim auth.smb username=smbuser password=redhat domain=MYGROUP chmod 600 auth.smb mkdir /database vim /etc/fstab # # /etc/fstab # Created by anaconda on Wed May 4 19:26:23 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/rhel-root / xfs defaults 1 1 UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2 /dev/mapper /rhel-swap swap swap defaults 0 0 /dev/cdrom /media/cdrom iso9660 defaults 0 0 //192.168.10.10/database /database cifs credentials=/root/auth.smb 0 0 mount -a cat /database/Memo.txt i can edit it .

浙ICP备11005866号-12