Install samba
1.linux访问windows
mount -t smbfs -o username=tridge,password=foobar //fjall/test /data/test
//fjall/test windows共享文件夹
/data/test 挂载点
umount –f test
2.windows访问linux
修改配置文件vi /etc/samba/smb.conf
定义Samba的安全级别,按从低到高分为四级:share,user,server,domain。它们对应的验证方式如下:
share:没有安全性的级别,任何用户都可以不要用户名和口令访问服务器上的资源。
user:samba的默认配置,要求用户在访问共享资源之前资源必须先提供用户名和密码进行验证。
server:和user安全级别类似,但用户名和密码是递交到另外一个服务器去验证,比如递交给一台NT服务器。如果递交失败,就退到user安全级。
domain:这个安全级别要求网络上存在一台Windows的主域控制器,samba把用户名和密码递交给它去验证。
后面三种安全级都要求用户在本linux机器上也要系统帐户。否则是不能访问的。
2个之间一定要用分号分开
访问权限问题则是共享文件夹的权限,chmod 777 ……..
访问用户在没有samba用户前提下,可用linux系统用户
smb用户建立
useradd lyn
passwd lyn
/etc/samba/smbpasswd –a lyn
/etc/samba/smbpasswd –e lyn
其密码可不同
service smb restart
[smb.conf 文件]
- ======================= Global Settings =====================================
- [global] //设置samba服务整体环境
- workgroup = hackase //设置工作组名
- server string = angel server //服务器名说明
- ; hosts allow = 192.168.1. 192.168.2. 127. //限制可访问此服务的IP范围,默认是全部允许的,要是想设设置去掉前面的";"
- printcap name = /etc/printcap //打印机配置文件
- load printers = yes //是否共享打印机
- # bsd, sysv, plp, lprng, aix, hpux, qnx, cups
- printing = cups //打印机的类型.标准打印机类型包括以上几种.
- ; guest account = pcguest //pcguest为用户名.可改去掉前边的";"让用户以
- pcguest身份匿名登录,但保证/etc/passwd中有此人.
- log file = /var/log/samba/%m.log //为登录服务器的用户建立不同的日志文件.
- max log size = 0 //日志文件的大小,"0"代表无限制
- //以下是smb.conf文件对服务器安全级别的设置
- security = share //安全性的级别共四种.share、user、server、domain
- ; password server = 密码验证服务器.
- ; password level = 8 //密码级别
- ; username level = 8
- encrypt passwords = yes //用户密码加密,当然也可以不加密
- smb passwd file = /etc/samba/smbpasswd //将密码服务器设置为samba server.
- 需要这个东东来指定验证文件.这个是文件的路径,如果samba server是指定的win
- server这个不需要
- ; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt
- unix password sync = Yes
- passwd program = /usr/bin/passwd %u
- passwd chat = *New*password* %n\n *Retype*new*password* %n\n
- *passwd:*all*authentication*tokens*updated*successfully*
- pam password change = yes
- ; username map = /etc/samba/smbusers //如果每个windows用户在samba服务器
- 中有帐户这个可以不设
- ; include = /etc/samba/smb.conf.%m
- obey pam restrictions = yes
- ; interfaces = 192.168.12.2/24 192.168.13.2/24 如果多网段要在这里列出
- ; remote announce = 192.168.1.255 192.168.2.44
- ; local master = no
- ; os level = 33
- ; domain master = yes
- ; preferred master = yes
- ; domain logons = yes
- ; logon script = %m.bat
- ; logon script = %U.bat
- ; logon path = \\%L\Profiles\%U
- ; wins support = yes //wins server支持
- ; wins server = w.x.y.z
- ; wins proxy = yes //wins 代理设置
- dns proxy = no //dns代理设置
- ; preserve case = no
- ; short preserve case = no
- ; default case = lower
- ; case sensitive = no
- #============================ Share Definitions ============================
- [homes] //用户访问自已目录的设置
- comment = Home Directories //说明(以下同理)
- browseable = no//设定目录可不可以别人浏览
- writeable = yes//用户写入自己的权限
- valid users = %S
- create mode = 0664
- directory mode = 0775
- ; [netlogon] //此段域用户登录目录设置
- ; comment = Network Logon Service
- ; path = /usr/local/samba/lib/netlogon
- ; guest ok = yes
- ; writable = no
- ; share modes = no
- ;[Profiles]
- ; path = /usr/local/samba/profiles
- ; browseable = no
- ; guest ok = yes
- [printers] //打印机设置
- comment = All Printers
- path = /var/spool/samba
- browseable = no
- printable = yes
- ;[tmp] //用户共享资源设置
- ; comment = Temporary file space
- ; path = /tmp //可以自定义目录,去掉前边的";"就OK了
- ; read only = no //是否只读或可写
- ; public = yes
- ;[public] //用户共享资源设置
- ; comment = Public Stuff
- ; path = /home/samba
- ; public = yes
- ; writable = yes
- ; printable = no
- ; write list = @staff
- ;[fredsprn]
- ; comment = Fred's Printer
- ; valid users = fred
- ; path = /home/fred
- ; printer = freds_printer
- ; public = no
- ; writable = no
- ; printable = yes
- ;[fredsdir]
- ; comment = Fred's Service
- ; path = /usr/somewhere/private
- ; valid users = fred
- ; public = no
- ; writable = yes
- ; printable = no
- ;[pchome]
- ; comment = PC Directories
- ; path = /usr/local/pc/%m
- ; public = no
- ; writable = yes
- ;[public]
- ; path = /usr/somewhere/else/public
- ; public = yes
- ; only guest = yes
- ; writable = yes
- ; printable = no
- ;[myshare]
- ; comment = Mary's and Fred's stuff
- ; path = /usr/somewhere/shared
- ; valid users = mary fred
- ; public = no
- ; writable = yes
- ; printable = no
- ; create mask = 0765
- [my work] //自己添加的共享资源
- comment = is me work
- path = /root/my work
- valid users angel
- public = yes
- writeable = yes
阅读(2062) | 评论(0) | 转发(0) |