[root@Oracle ~]# yum install samba-swat -y
[root@Oracle ~]# yum install samba-client 客户端工具
主配置文件:
[root@Oracle ~]# cat /etc/samba/smb.conf |grep -v "#"|grep -v "^$"|grep -v ";"
[global]
workgroup = MYGROUP 服务器所在的工作组
server string = Samba Server Version %v 服务器的名称
log file = /var/log/samba/log.%m 日志文件存在的位置
max log size = 50 日志文件的大小
security = user 安全级别
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
几个samba参数
smbpasswd -a username
pdbedit -a username 新建用户
-x username 删除用户
-L 查看用户
-Lv 详细信息
-c "[D]" -u username 停用账户
-c "[]" -u username 恢复账户
一个简单的共享配置:
[public] 共享名
comment = this is my first project 描述
path = /mnt 共享的路径
writeable = no 是否可写
read only = yes 是否只读
public = yes 公共
hosts deny = 192.168.1.0/24 可以禁止网段访问 此处allow优先级大于deny
hosts allow = 10.0.0.11 10.0.0.10 ip地址和域名都可以
hosts allow = 10.0.0.0 EXCEPT 10.0.0.11 10.0.0.10 在某网段中排出某台机器
[root@Oracle ~]# service smb restart 重启smb服务
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@Oracle ~]# smbpasswd -a root 设置root密码
New SMB password: 123456
Retype new SMB password: 123456
Added user root.
[root@Oracle ~]# yum install samba-client 客户端工具
[root@Oracle ~]# smbclient -L 10.0.0.10 客户端测试本地是否正常
Enter root's password: 输入root密码,注意此处是samba设置的密码
Enter root's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-24.el6_7]
Sharename Type Comment
--------- ---- -------
public Disk this is my first project
IPC$ IPC IPC Service (Samba Server Version 3.6.23-24.el6_7)
root Disk Home Directories
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-24.el6_7]
Server Comment
--------- -------
Workgroup Master
--------- -------
######################################用户映射##############################################
[root@Oracle samba]# vim /etc/samba/smbusers
# Unix_name = SMB_name1 SMB_name2 ...
root = administrator admin
nobody = guest pcguest smbguest
technology = user1 user2 user3 user4 =====>名称映射,前面的是真实名称,后面的是假名
[root@Oracle samba]# /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@Oracle samba]# useradd technology --添加用户
[root@Oracle samba]# smbpasswd -a technology --添加用户的smb密码
New SMB password:afocus
Retype new SMB password:afocus
Added user technology.
[root@Oracle samba]# id -u technology 用户已建立
500
[root@Oracle samba]# vim /etc/samba/smb.conf
[global]
username map = /etc/samba/smbusers
[root@Oracle samba]# /etc/init.d/smb restart 重启服务
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
[root@Oracle samba]# smbclient //10.0.0.10/public -U user1 之后就可以用映射的用户进入了
客户端:
查看共享连接两种方式:
windows下的访问方式:\\10.0.0.10
Linux客户端的访问方式:smbclient -L 10.0.0.10 -U user2
访问共享
[root@Oracle samba]# smbclient //10.0.0.10/public -U user2
windows下的访问方式:\\10.0.0.10\public
客户端挂载
mkdir /mnt/abc
mount -t cifs //10.0.0.10/public /mnt/abc -o username=technology
本文转自陈继松 51CTO博客,原文链接:http://blog.51cto.com/chenjisong/1738509,如需转载请自行联系原作者